pub trait InferCtxtExt<'tcx> {
    // Required methods
    fn predicate_may_hold(&self, obligation: &PredicateObligation<'tcx>) -> bool;
    fn predicate_must_hold_considering_regions(
        &self,
        obligation: &PredicateObligation<'tcx>
    ) -> bool;
    fn predicate_must_hold_modulo_regions(
        &self,
        obligation: &PredicateObligation<'tcx>
    ) -> bool;
    fn evaluate_obligation(
        &self,
        obligation: &PredicateObligation<'tcx>
    ) -> Result<EvaluationResult, OverflowError>;
    fn evaluate_obligation_no_overflow(
        &self,
        obligation: &PredicateObligation<'tcx>
    ) -> EvaluationResult;
}

Required Methods§

source

fn predicate_may_hold(&self, obligation: &PredicateObligation<'tcx>) -> bool

Evaluates whether the predicate can be satisfied (by any means) in the given ParamEnv.

source

fn predicate_must_hold_considering_regions( &self, obligation: &PredicateObligation<'tcx> ) -> bool

Evaluates whether the predicate can be satisfied in the given ParamEnv, and returns false if not certain. However, this is not entirely accurate if inference variables are involved.

This version may conservatively fail when outlives obligations are required. Therefore, this version should only be used for optimizations or diagnostics and be treated as if it can always return false.

§Example
trait Trait {}

fn check<T: Trait>() {}

fn foo<T: 'static>()
where
    &'static T: Trait,
{
    // Evaluating `&'?0 T: Trait` adds a `'?0: 'static` outlives obligation,
    // which means that `predicate_must_hold_considering_regions` will return
    // `false`.
    check::<&'_ T>();
}
source

fn predicate_must_hold_modulo_regions( &self, obligation: &PredicateObligation<'tcx> ) -> bool

Evaluates whether the predicate can be satisfied in the given ParamEnv, and returns false if not certain. However, this is not entirely accurate if inference variables are involved.

This version ignores all outlives constraints.

source

fn evaluate_obligation( &self, obligation: &PredicateObligation<'tcx> ) -> Result<EvaluationResult, OverflowError>

Evaluate a given predicate, capturing overflow and propagating it back.

source

fn evaluate_obligation_no_overflow( &self, obligation: &PredicateObligation<'tcx> ) -> EvaluationResult

Helper function that canonicalizes and runs the query. If an overflow results, we re-run it in the local context so we can report a nice error.

Implementors§

source§

impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx>