Struct rustc_trait_selection::traits::engine::ObligationCtxt
source · pub struct ObligationCtxt<'a, 'tcx> {
pub infcx: &'a InferCtxt<'a, 'tcx>,
engine: RefCell<Box<dyn TraitEngine<'tcx>>>,
}
Expand description
Used if you want to have pleasant experience when dealing with obligations outside of hir or mir typeck.
Fields
infcx: &'a InferCtxt<'a, 'tcx>
engine: RefCell<Box<dyn TraitEngine<'tcx>>>
Implementations
sourceimpl<'a, 'tcx> ObligationCtxt<'a, 'tcx>
impl<'a, 'tcx> ObligationCtxt<'a, 'tcx>
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self
pub fn new_in_snapshot(infcx: &'a InferCtxt<'a, 'tcx>) -> Self
pub fn register_obligation(&self, obligation: PredicateObligation<'tcx>)
pub fn register_obligations(
&self,
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>
)
pub fn register_infer_ok_obligations<T>(&self, infer_ok: InferOk<'tcx, T>) -> T
sourcepub fn register_bound(
&self,
cause: ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
ty: Ty<'tcx>,
def_id: DefId
)
pub fn register_bound(
&self,
cause: ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
ty: Ty<'tcx>,
def_id: DefId
)
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 normalize<T: TypeFoldable<'tcx>>(
&self,
cause: ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
value: T
) -> T
pub fn equate_types(
&self,
cause: &ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
expected: Ty<'tcx>,
actual: Ty<'tcx>
) -> Result<(), TypeError<'tcx>>
pub fn select_all_or_error(&self) -> Vec<FulfillmentError<'tcx>>
pub fn assumed_wf_types(
&self,
param_env: ParamEnv<'tcx>,
span: Span,
def_id: LocalDefId
) -> FxHashSet<Ty<'tcx>>
Auto Trait Implementations
impl<'a, 'tcx> !RefUnwindSafe for ObligationCtxt<'a, 'tcx>
impl<'a, 'tcx> !Send for ObligationCtxt<'a, 'tcx>
impl<'a, 'tcx> !Sync for ObligationCtxt<'a, 'tcx>
impl<'a, 'tcx> Unpin for ObligationCtxt<'a, 'tcx>where
'tcx: 'a,
impl<'a, 'tcx> !UnwindSafe for ObligationCtxt<'a, 'tcx>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes