Struct ObligationCtxt
pub struct ObligationCtxt<'a, 'db> {
pub infcx: &'a InferCtxt<'db>,
/* private fields */
}Expand description
Used if you want to have pleasant experience when dealing with obligations outside of hir or mir typeck.
Fields§
§infcx: &'a InferCtxt<'db>Implementations§
§impl<'a, 'db> ObligationCtxt<'a, 'db>
impl<'a, 'db> ObligationCtxt<'a, 'db>
pub fn new(infcx: &'a InferCtxt<'db>) -> ObligationCtxt<'a, 'db>
§impl<'a, 'db> ObligationCtxt<'a, 'db>
impl<'a, 'db> ObligationCtxt<'a, 'db>
pub fn register_obligation( &mut self, obligation: Obligation<'db, Predicate<'db>>, )
pub fn register_obligations( &mut self, obligations: impl IntoIterator<Item = Obligation<'db, Predicate<'db>>>, )
pub fn register_infer_ok_obligations<T>( &mut self, infer_ok: InferOk<'db, T>, ) -> T
pub fn register_bound(
&mut self,
cause: ObligationCause,
param_env: ParamEnv<'db>,
ty: Ty<'db>,
def_id: TraitId,
)
pub fn register_bound( &mut self, cause: ObligationCause, param_env: ParamEnv<'db>, ty: Ty<'db>, def_id: TraitId, )
Requires that ty must implement the trait with def_id in
the given environment. This trait must not have any type
parameters (except for Self).
pub fn eq<T>(
&mut self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
expected: T,
actual: T,
) -> Result<(), TypeError<DbInterner<'db>>>where
T: ToTrace<'db>,
pub fn sub<T>(
&mut self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
expected: T,
actual: T,
) -> Result<(), TypeError<DbInterner<'db>>>where
T: ToTrace<'db>,
pub fn sub<T>(
&mut self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
expected: T,
actual: T,
) -> Result<(), TypeError<DbInterner<'db>>>where
T: ToTrace<'db>,
Checks whether expected is a subtype of actual: expected <: actual.
pub fn relate<T>(
&mut self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
variance: Variance,
expected: T,
actual: T,
) -> Result<(), TypeError<DbInterner<'db>>>where
T: ToTrace<'db>,
pub fn sup<T>(
&mut self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
expected: T,
actual: T,
) -> Result<(), TypeError<DbInterner<'db>>>where
T: ToTrace<'db>,
pub fn sup<T>(
&mut self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
expected: T,
actual: T,
) -> Result<(), TypeError<DbInterner<'db>>>where
T: ToTrace<'db>,
Checks whether expected is a supertype of actual: expected :> actual.
pub fn lub<T>(
&mut self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
expected: T,
actual: T,
) -> Result<T, TypeError<DbInterner<'db>>>where
T: ToTrace<'db>,
pub fn lub<T>(
&mut self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
expected: T,
actual: T,
) -> Result<T, TypeError<DbInterner<'db>>>where
T: ToTrace<'db>,
Computes the least-upper-bound, or mutual supertype, of two values.
pub fn try_evaluate_obligations(&mut self) -> Vec<NextSolverError<'db>>
pub fn evaluate_obligations_error_on_ambiguity( &mut self, ) -> Vec<NextSolverError<'db>>
pub fn into_pending_obligations(self) -> Vec<Obligation<'db, Predicate<'db>>>
pub fn into_pending_obligations(self) -> Vec<Obligation<'db, Predicate<'db>>>
Returns the not-yet-processed and stalled obligations from the
ObligationCtxt.
Takes ownership of the context as doing operations such as
ObligationCtxt::eq afterwards will result in other obligations
getting ignored. You can make a new ObligationCtxt if this
needs to be done in a loop, for example.
pub fn deeply_normalize<T>(
&self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
value: T,
) -> Result<T, Vec<NextSolverError<'db>>>where
T: TypeFoldable<DbInterner<'db>>,
pub fn structurally_normalize_ty( &mut self, cause: &ObligationCause, param_env: ParamEnv<'db>, value: Ty<'db>, ) -> Result<Ty<'db>, Vec<NextSolverError<'db>>>
pub fn structurally_normalize_const( &mut self, cause: &ObligationCause, param_env: ParamEnv<'db>, value: Const<'db>, ) -> Result<Const<'db>, Vec<NextSolverError<'db>>>
pub fn structurally_normalize_term( &mut self, cause: &ObligationCause, param_env: ParamEnv<'db>, value: Term<'db>, ) -> Result<Term<'db>, Vec<NextSolverError<'db>>>
Auto Trait Implementations§
impl<'a, 'db> Freeze for ObligationCtxt<'a, 'db>
impl<'a, 'db> !RefUnwindSafe for ObligationCtxt<'a, 'db>
impl<'a, 'db> !Send for ObligationCtxt<'a, 'db>
impl<'a, 'db> !Sync for ObligationCtxt<'a, 'db>
impl<'a, 'db> Unpin for ObligationCtxt<'a, 'db>
impl<'a, 'db> !UnwindSafe for ObligationCtxt<'a, 'db>
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
Mutably borrows from an owned value. Read more
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> 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>
Converts
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>
Converts
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