Struct Obligation
pub struct Obligation<'db, T> {
pub cause: ObligationCause,
pub param_env: ParamEnv<'db>,
pub predicate: T,
pub recursion_depth: usize,
}Expand description
An Obligation represents some trait reference (e.g., i32: Eq) for
which the “impl_source” must be found. The process of finding an “impl_source” is
called “resolving” the Obligation. This process consists of
either identifying an impl (e.g., impl Eq for i32) that
satisfies the obligation, or else finding a bound that is in
scope. The eventual result is usually a Selection (defined below).
Fields§
§cause: ObligationCauseThe reason we have to prove this thing.
param_env: ParamEnv<'db>The environment in which we should prove this thing.
predicate: TThe thing we are trying to prove.
recursion_depth: usizeIf we started proving this as a result of trying to prove something else, track the total depth to ensure termination. If this goes over a certain threshold, we abort compilation – in such cases, we can not say whether or not the predicate holds for certain. Stupid halting problem; such a drag.
Implementations§
§impl<'db, T> Obligation<'db, T>where
T: Copy,
impl<'db, T> Obligation<'db, T>where
T: Copy,
pub fn as_goal(&self) -> Goal<DbInterner<'db>, T>
§impl<'db> Obligation<'db, Predicate<'db>>
impl<'db> Obligation<'db, Predicate<'db>>
pub fn flip_polarity(
&self,
_interner: DbInterner<'db>,
) -> Option<Obligation<'db, Predicate<'db>>>
pub fn flip_polarity( &self, _interner: DbInterner<'db>, ) -> Option<Obligation<'db, Predicate<'db>>>
Flips the polarity of the inner predicate.
Given T: Trait predicate it returns T: !Trait and given T: !Trait returns T: Trait.
§impl<'db, O> Obligation<'db, O>
impl<'db, O> Obligation<'db, O>
pub fn new( interner: DbInterner<'db>, cause: ObligationCause, param_env: ParamEnv<'db>, predicate: impl Upcast<DbInterner<'db>, O>, ) -> Obligation<'db, O>
pub fn set_depth_from_parent(&mut self, parent_depth: usize)
pub fn set_depth_from_parent(&mut self, parent_depth: usize)
We often create nested obligations without setting the correct depth.
To deal with this evaluate and fulfill explicitly update the depth of nested obligations using this function.
pub fn with_depth( interner: DbInterner<'db>, cause: ObligationCause, recursion_depth: usize, param_env: ParamEnv<'db>, predicate: impl Upcast<DbInterner<'db>, O>, ) -> Obligation<'db, O>
pub fn with<P>( &self, tcx: DbInterner<'db>, value: impl Upcast<DbInterner<'db>, P>, ) -> Obligation<'db, P>
Trait Implementations§
§impl<'db, T> Clone for Obligation<'db, T>where
T: Clone,
impl<'db, T> Clone for Obligation<'db, T>where
T: Clone,
§fn clone(&self) -> Obligation<'db, T>
fn clone(&self) -> Obligation<'db, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<'db, T> Debug for Obligation<'db, T>where
T: Debug,
impl<'db, T> Debug for Obligation<'db, T>where
T: Debug,
§impl<'db> Elaboratable<DbInterner<'db>> for Obligation<'db, Predicate<'db>>
For Obligation, a sub-obligation is combined with the current obligation’s
param-env and cause code.
impl<'db> Elaboratable<DbInterner<'db>> for Obligation<'db, Predicate<'db>>
For Obligation, a sub-obligation is combined with the current obligation’s
param-env and cause code.
fn predicate(&self) -> Predicate<'db>
fn child(&self, clause: Clause<'db>) -> Obligation<'db, Predicate<'db>>
fn child_with_derived_cause( &self, clause: Clause<'db>, span: Span, _parent_trait_pred: Binder<DbInterner<'db>, TraitPredicate<DbInterner<'db>>>, _index: usize, ) -> Obligation<'db, Predicate<'db>>
§impl<'db, P> From<Obligation<'db, P>> for Goal<DbInterner<'db>, P>
impl<'db, P> From<Obligation<'db, P>> for Goal<DbInterner<'db>, P>
§fn from(value: Obligation<'db, P>) -> Goal<DbInterner<'db>, P>
fn from(value: Obligation<'db, P>) -> Goal<DbInterner<'db>, P>
§impl<'db, T> Hash for Obligation<'db, T>where
T: Hash,
impl<'db, T> Hash for Obligation<'db, T>where
T: Hash,
§impl<'db, T> PartialEq for Obligation<'db, T>where
T: PartialEq,
impl<'db, T> PartialEq for Obligation<'db, T>where
T: PartialEq,
§impl<'db, T> TypeFoldable<DbInterner<'db>> for Obligation<'db, T>where
T: TypeFoldable<DbInterner<'db>>,
impl<'db, T> TypeFoldable<DbInterner<'db>> for Obligation<'db, T>where
T: TypeFoldable<DbInterner<'db>>,
§fn try_fold_with<__F>(
self,
__folder: &mut __F,
) -> Result<Obligation<'db, T>, <__F as FallibleTypeFolder<DbInterner<'db>>>::Error>where
__F: FallibleTypeFolder<DbInterner<'db>>,
fn try_fold_with<__F>(
self,
__folder: &mut __F,
) -> Result<Obligation<'db, T>, <__F as FallibleTypeFolder<DbInterner<'db>>>::Error>where
__F: FallibleTypeFolder<DbInterner<'db>>,
§fn fold_with<__F>(self, __folder: &mut __F) -> Obligation<'db, T>where
__F: TypeFolder<DbInterner<'db>>,
fn fold_with<__F>(self, __folder: &mut __F) -> Obligation<'db, T>where
__F: TypeFolder<DbInterner<'db>>,
§impl<'db, T> TypeVisitable<DbInterner<'db>> for Obligation<'db, T>where
T: TypeVisitable<DbInterner<'db>>,
impl<'db, T> TypeVisitable<DbInterner<'db>> for Obligation<'db, T>where
T: TypeVisitable<DbInterner<'db>>,
§fn visit_with<__V>(
&self,
__visitor: &mut __V,
) -> <__V as TypeVisitor<DbInterner<'db>>>::Resultwhere
__V: TypeVisitor<DbInterner<'db>>,
fn visit_with<__V>(
&self,
__visitor: &mut __V,
) -> <__V as TypeVisitor<DbInterner<'db>>>::Resultwhere
__V: TypeVisitor<DbInterner<'db>>,
impl<'db, T> Eq for Obligation<'db, T>where
T: Eq,
Auto Trait Implementations§
impl<'db, T> Freeze for Obligation<'db, T>where
T: Freeze,
impl<'db, T> RefUnwindSafe for Obligation<'db, T>where
T: RefUnwindSafe,
impl<'db, T> Send for Obligation<'db, T>where
T: Send,
impl<'db, T> Sync for Obligation<'db, T>where
T: Sync,
impl<'db, T> Unpin for Obligation<'db, T>where
T: Unpin,
impl<'db, T> UnsafeUnpin for Obligation<'db, T>where
T: UnsafeUnpin,
impl<'db, T> UnwindSafe for Obligation<'db, T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> HashEqLike<T> for T
impl<T> HashEqLike<T> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Lookup<T> for T
impl<T> Lookup<T> for T
fn into_owned(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<I, T> TypeVisitableExt<I> for Twhere
I: Interner,
T: TypeVisitable<I>,
impl<I, T> TypeVisitableExt<I> for Twhere
I: Interner,
T: TypeVisitable<I>,
fn has_type_flags(&self, flags: TypeFlags) -> bool
§fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
true if self has any late-bound regions that are either
bound by binder or bound by some binder outside of binder.
If binder is ty::INNERMOST, this indicates whether
there are any late-bound regions that appear free.fn error_reported(&self) -> Result<(), <I as Interner>::ErrorGuaranteed>
fn non_region_error_reported( &self, ) -> Result<(), <I as Interner>::ErrorGuaranteed>
§fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool
fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool
true if this type has any regions that escape binder (and
hence are not bound by it).§fn has_escaping_bound_vars(&self) -> bool
fn has_escaping_bound_vars(&self) -> bool
true if this type has regions that are not a part of the
type. For example, given a for<'a> fn(&'a i32) this function returns
false, while given a fn(&'a i32) it returns true. The latter can
occur when traversing through the former. Read morefn has_aliases(&self) -> bool
fn has_opaque_types(&self) -> bool
fn has_coroutines(&self) -> bool
fn references_error(&self) -> bool
fn has_non_region_param(&self) -> bool
fn has_regions(&self) -> bool
fn has_infer_regions(&self) -> bool
fn has_infer_types(&self) -> bool
fn has_non_region_infer(&self) -> bool
fn has_infer(&self) -> bool
fn has_placeholders(&self) -> bool
fn has_non_region_placeholders(&self) -> bool
fn has_param(&self) -> bool
§fn has_free_regions(&self) -> bool
fn has_free_regions(&self) -> bool
fn has_erased_regions(&self) -> bool
§fn has_erasable_regions(&self) -> bool
fn has_erasable_regions(&self) -> bool
§fn is_global(&self) -> bool
fn is_global(&self) -> bool
§fn has_bound_regions(&self) -> bool
fn has_bound_regions(&self) -> bool
§fn has_non_region_bound_vars(&self) -> bool
fn has_non_region_bound_vars(&self) -> bool
§fn has_bound_vars(&self) -> bool
fn has_bound_vars(&self) -> bool
§fn still_further_specializable(&self) -> bool
fn still_further_specializable(&self) -> bool
impl
specialization.