Skip to content

Commit 08b8b38

Browse files
committed
WIP error bounds
1 parent 558c44b commit 08b8b38

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

scopegraphs/src/containers/env.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ where
134134
}
135135
}
136136

137-
impl<'sg: 'rslv, 'rslv, LABEL: 'sg + Eq, DATA: 'sg + Eq, E: 'rslv>
137+
/* impl<'sg: 'rslv, 'rslv, LABEL: 'sg + Eq, DATA: 'sg + Eq, E: 'rslv>
138138
Injectable<'sg, 'rslv, LABEL, DATA, Result<bool, E>> for Result<Env<'sg, LABEL, DATA>, E>
139139
where
140140
ResolvedPath<'sg, LABEL, DATA>: Hash + Clone,
@@ -143,7 +143,7 @@ where
143143
fn inject_if(data_ok: Result<bool, E>, path: ResolvedPath<'sg, LABEL, DATA>) -> Self {
144144
data_ok.map(|ok| if ok { Env::single(path) } else { Env::empty() })
145145
}
146-
}
146+
} */
147147

148148
impl<'sg: 'rslv, 'rslv, LABEL: 'sg + Eq, DATA: 'sg + Eq, RE, UE>
149149
Injectable<'sg, 'rslv, LABEL, DATA, Result<bool, RE>>

scopegraphs/src/containers/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! by [`Completeness`](crate::completeness::Completeness) implementations.
55
66
/// Union of errors during resolution (i.e., delays) and error during predicate evaluation.
7+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
78
pub enum ResolveOrUserError<RE, UE> {
89
/// Resolution error.
910
Resolve(RE),

scopegraphs/src/containers/scope.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub trait ScopeContainer<'sg, 'rslv, LABEL: Debug + 'sg, DATA: 'sg>: Debug {
2626
/// - [Result] of scope containers, and
2727
/// - [FutureWrapper] of scope containers.
2828
/// ```
29-
/// # use scopegraphs::containers::ScopeContainerWf;
29+
/// # use scopegraphs::containers::{ResolveOrUserError,ScopeContainerWf};
3030
/// # use scopegraphs::future_wrapper::FutureWrapper;
3131
/// # use scopegraphs::Scope;
3232
/// # use std::fmt::Debug;
@@ -44,10 +44,11 @@ pub trait ScopeContainer<'sg, 'rslv, LABEL: Debug + 'sg, DATA: 'sg>: Debug {
4444
/// test::<'_, '_, LABEL, DATA, bool>(vec);
4545
/// # }
4646
///
47-
/// # fn result<'sg, 'rslv, LABEL: LBound<'sg>, DATA: DBound<'sg>, E: Debug + Clone>() {
48-
/// let result: Result<Vec<Scope>, E> = todo!();
47+
/// # fn result<'sg, 'rslv, LABEL: LBound<'sg>, DATA: DBound<'sg>, RE: Debug + Clone + 'rslv, UE: Debug + Clone + 'rslv>() {
48+
/// let result: Result<Vec<Scope>, RE> = todo!();
4949
/// test::<'_, '_, LABEL, DATA, bool>(result);
50-
/// test::<'_, '_, LABEL, DATA, Result<bool, E>>(result);
50+
/// let result_or_err: Result<Vec<Scope>, ResolveOrUserError<RE, UE>> = todo!();
51+
/// test::<'_, '_, LABEL, DATA, Result<bool, UE>>(result_or_err);
5152
/// # }
5253
///
5354
/// # fn future<'sg, 'rslv, LABEL: LBound<'sg>, DATA: DBound<'sg>>() {
@@ -70,13 +71,13 @@ pub trait ScopeContainer<'sg, 'rslv, LABEL: Debug + 'sg, DATA: 'sg>: Debug {
7071
/// ```
7172
///
7273
/// ```no_run
73-
/// # use scopegraphs::containers::ScopeContainerWf;
74+
/// # use scopegraphs::containers::{ResolveOrUserError, ScopeContainerWf};
7475
/// # use scopegraphs::Scope;
7576
/// # use std::fmt::Debug;
7677
/// # use std::hash::Hash;
7778
///
7879
/// test::<'_, '_, (), (), bool>(Result::<_, ()>::Ok(Vec::<Scope>::new()));
79-
/// test::<'_, '_, (), (), Result<bool, ()>>(Result::<_, ()>::Ok(Vec::<Scope>::new()));
80+
/// test::<'_, '_, (), (), Result<bool, ()>>(Result::<_, ResolveOrUserError<(), ()>>::Ok(Vec::<Scope>::new()));
8081
///
8182
/// fn test<'sg, 'rslv, LABEL: Clone + Hash + Eq + Debug + 'sg, DATA: Hash + Eq + 'sg, DWFO>(
8283
/// cont: impl ScopeContainerWf<'sg, 'rslv, LABEL, DATA, DWFO, DWFO>

scopegraphs/src/resolve/lookup.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -342,18 +342,14 @@ where
342342
#[cfg(test)]
343343
mod tests {
344344

345+
use std::convert::Infallible;
346+
345347
use scopegraphs_macros::label_order;
346348

347349
use crate::{
348-
add_scope,
349-
completeness::{
350+
add_scope, completeness::{
350351
Delay, ExplicitClose, FutureCompleteness, ImplicitClose, UncheckedCompleteness,
351-
},
352-
future_wrapper::FutureWrapper,
353-
query_regex,
354-
resolve::{Resolve, ResolvedPath},
355-
storage::Storage,
356-
Label, ScopeGraph,
352+
}, containers::ResolveOrUserError, future_wrapper::FutureWrapper, query_regex, resolve::{Resolve, ResolvedPath}, storage::Storage, Label, ScopeGraph
357353
};
358354

359355
#[derive(Label, Hash, PartialEq, Eq, Debug, Clone, Copy)]
@@ -392,7 +388,7 @@ mod tests {
392388
|data: &Self| data.matches(n)
393389
}
394390

395-
fn matcher_res(n: &'a str) -> impl (for<'b> Fn(&'b Self) -> Result<bool, Delay<Lbl>>) {
391+
fn matcher_res(n: &'a str) -> impl (for<'b> Fn(&'b Self) -> Result<bool, Infallible>) {
396392
|data: &Self| Ok(data.matches(n))
397393
}
398394

@@ -658,7 +654,7 @@ mod tests {
658654
// todo!("assert the correct edges are closed!")
659655
}
660656

661-
#[test]
657+
/* #[test]
662658
fn test_label_order_complex_explicit_close() {
663659
let storage = Storage::new();
664660
let scope_graph: ScopeGraph<Lbl, TData, ExplicitClose<Lbl>> =
@@ -692,7 +688,7 @@ mod tests {
692688
let_lex.close();
693689
let_def.close();
694690
695-
let env = scope_graph
691+
let env: Result<_, ResolveOrUserError<_, Infallible>> = scope_graph
696692
.query()
697693
.with_path_wellformedness(query_regex!(Lbl: Lex* Imp? Def))
698694
.with_data_wellformedness(TData::matcher_res("x"))
@@ -707,7 +703,7 @@ mod tests {
707703
assert!(matches!(path.data(), &Data { name: "x", data: 2 }));
708704
709705
// todo!("assert the correct edges are closed!")
710-
}
706+
}*/
711707

712708
#[test]
713709
fn test_caching() {

0 commit comments

Comments
 (0)