pub struct EvalCtxt<'a, 'tcx> {
    pub(super) infcx: &'a InferCtxt<'tcx>,
    pub(super) var_values: CanonicalVarValues<'tcx>,
    pub(super) max_input_universe: UniverseIndex,
    pub(super) search_graph: &'a mut SearchGraph<'tcx>,
    pub in_projection_eq_hack: bool,
}

Fields§

§infcx: &'a InferCtxt<'tcx>§var_values: CanonicalVarValues<'tcx>§max_input_universe: UniverseIndex

The highest universe index nameable by the caller.

When we enter a new binder inside of the query we create new universes which the caller cannot name. We have to be careful with variables from these new universes when creating the query response.

Both because these new universes can prevent us from reaching a fixpoint if we have a coinductive cycle and because that’s the only way we can return new placeholders to the caller.

§search_graph: &'a mut SearchGraph<'tcx>§in_projection_eq_hack: bool

This field is used by a debug assertion in EvalCtxt::evaluate_goal, see the comment in that method for more details.

Implementations§

source§

impl<'tcx> EvalCtxt<'_, 'tcx>

source

pub(super) fn assemble_and_evaluate_candidates<G: GoalKind<'tcx>>( &mut self, goal: Goal<'tcx, G> ) -> Vec<Candidate<'tcx>>

source

fn assemble_candidates_after_normalizing_self_ty<G: GoalKind<'tcx>>( &mut self, goal: Goal<'tcx, G>, candidates: &mut Vec<Candidate<'tcx>> )

If the self type of a goal is a projection, computing the relevant candidates is difficult.

To deal with this, we first try to normalize the self type and add the candidates for the normalized self type to the list of candidates in case that succeeds. Note that we can’t just eagerly return in this case as projections as self types add

source

fn assemble_impl_candidates<G: GoalKind<'tcx>>( &mut self, goal: Goal<'tcx, G>, candidates: &mut Vec<Candidate<'tcx>> )

source

fn assemble_builtin_impl_candidates<G: GoalKind<'tcx>>( &mut self, goal: Goal<'tcx, G>, candidates: &mut Vec<Candidate<'tcx>> )

source

fn assemble_param_env_candidates<G: GoalKind<'tcx>>( &mut self, goal: Goal<'tcx, G>, candidates: &mut Vec<Candidate<'tcx>> )

source

fn assemble_alias_bound_candidates<G: GoalKind<'tcx>>( &mut self, goal: Goal<'tcx, G>, candidates: &mut Vec<Candidate<'tcx>> )

source

fn assemble_object_bound_candidates<G: GoalKind<'tcx>>( &mut self, goal: Goal<'tcx, G>, candidates: &mut Vec<Candidate<'tcx>> )

source

pub(super) fn merge_candidates_and_discard_reservation_impls( &mut self, candidates: Vec<Candidate<'tcx>> ) -> QueryResult<'tcx>

source

fn trait_candidate_should_be_dropped_in_favor_of( &self, candidate: &Candidate<'tcx>, other: &Candidate<'tcx> ) -> bool

source

fn discard_reservation_impl( &self, candidate: Candidate<'tcx> ) -> Candidate<'tcx>

source§

impl<'tcx> EvalCtxt<'_, 'tcx>

source

pub(super) fn canonicalize_goal( &self, goal: Goal<'tcx, Predicate<'tcx>> ) -> (Vec<GenericArg<'tcx>>, CanonicalGoal<'tcx>)

Canonicalizes the goal remembering the original values for each bound variable.

source

pub(super) fn make_canonical_response( &self, certainty: Certainty ) -> QueryResult<'tcx>

To return the constraints of a canonical query to the caller, we canonicalize:

  • var_values: a map from bound variables in the canonical goal to the values inferred while solving the instantiated goal.
  • external_constraints: additional constraints which aren’t expressable using simple unification of inference variables.
source

fn compute_external_query_constraints( &self ) -> Result<ExternalConstraints<'tcx>, NoSolution>

source

pub(super) fn instantiate_and_apply_query_response( &mut self, param_env: ParamEnv<'tcx>, original_values: Vec<GenericArg<'tcx>>, response: CanonicalResponse<'tcx> ) -> Result<Certainty, NoSolution>

After calling a canonical query, we apply the constraints returned by the query using this function.

This happens in three steps:

  • we instantiate the bound variables of the query response
  • we unify the var_values of the response with the original_values
  • we apply the external_constraints returned by the query
source

fn compute_query_response_substitution( &self, original_values: &[GenericArg<'tcx>], response: &CanonicalResponse<'tcx> ) -> CanonicalVarValues<'tcx>

This returns the substitutions to instantiate the bound variables of the canonical reponse. This depends on the original_values for the bound variables.

source

fn unify_query_var_values( &self, param_env: ParamEnv<'tcx>, original_values: &[GenericArg<'tcx>], var_values: CanonicalVarValues<'tcx> ) -> Result<(), NoSolution>

source

fn register_region_constraints( &mut self, region_constraints: &QueryRegionConstraints<'tcx> )

source§

impl<'tcx> EvalCtxt<'_, 'tcx>

source

pub(super) fn probe<T>( &mut self, f: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> T ) -> T

source

pub(super) fn tcx(&self) -> TyCtxt<'tcx>

source

pub(super) fn next_ty_infer(&self) -> Ty<'tcx>

source

pub(super) fn next_const_infer(&self, ty: Ty<'tcx>) -> Const<'tcx>

source

pub(super) fn term_is_fully_unconstrained( &self, goal: Goal<'tcx, ProjectionPredicate<'tcx>> ) -> bool

Is the projection predicate is of the form exists<T> <Ty as Trait>::Assoc = T.

This is the case if the term is an inference variable in the innermost universe and does not occur in any other part of the predicate.

source

pub(super) fn eq<T: ToTrace<'tcx>>( &self, param_env: ParamEnv<'tcx>, lhs: T, rhs: T ) -> Result<Vec<Goal<'tcx, Predicate<'tcx>>>, NoSolution>

source

pub(super) fn instantiate_binder_with_infer<T: TypeFoldable<TyCtxt<'tcx>> + Copy>( &self, value: Binder<'tcx, T> ) -> T

source

pub(super) fn instantiate_binder_with_placeholders<T: TypeFoldable<TyCtxt<'tcx>> + Copy>( &self, value: Binder<'tcx, T> ) -> T

source

pub(super) fn resolve_vars_if_possible<T>(&self, value: T) -> Twhere T: TypeFoldable<TyCtxt<'tcx>>,

source

pub(super) fn fresh_substs_for_item(&self, def_id: DefId) -> SubstsRef<'tcx>

source

pub(super) fn universe(&self) -> UniverseIndex

source§

impl<'tcx> EvalCtxt<'_, 'tcx>

source

pub(super) fn compute_projection_goal( &mut self, goal: Goal<'tcx, ProjectionPredicate<'tcx>> ) -> QueryResult<'tcx>

source

fn in_projection_eq_hack<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T

This sets a flag used by a debug assert in EvalCtxt::evaluate_goal, see the comment in that method for more details.

source

fn eq_term_and_make_canonical_response( &mut self, goal: Goal<'tcx, ProjectionPredicate<'tcx>>, normalization_certainty: Certainty, normalized_alias: impl Into<Term<'tcx>> ) -> QueryResult<'tcx>

After normalizing the projection to normalized_alias with the given normalization_certainty, constrain the inference variable term to it and return a query response.

source§

impl<'tcx> EvalCtxt<'_, 'tcx>

source

fn probe_and_evaluate_goal_for_constituent_tys( &mut self, goal: Goal<'tcx, TraitPredicate<'tcx>>, constituent_tys: impl Fn(&EvalCtxt<'_, 'tcx>, Ty<'tcx>) -> Result<Vec<Ty<'tcx>>, NoSolution> ) -> QueryResult<'tcx>

Convenience function for traits that are structural, i.e. that only have nested subgoals that only change the self type. Unlike other evaluate-like helpers, this does a probe, so it doesn’t need to be wrapped in one.

source

pub(super) fn compute_trait_goal( &mut self, goal: Goal<'tcx, TraitPredicate<'tcx>> ) -> QueryResult<'tcx>

source§

impl<'a, 'tcx> EvalCtxt<'a, 'tcx>

source

fn evaluate_canonical_goal( tcx: TyCtxt<'tcx>, search_graph: &'a mut SearchGraph<'tcx>, canonical_goal: CanonicalGoal<'tcx> ) -> QueryResult<'tcx>

The entry point of the solver.

This function deals with (coinductive) cycles, overflow, and caching and then calls EvalCtxt::compute_goal which contains the actual logic of the solver.

Instead of calling this function directly, use either EvalCtxt::evaluate_goal if you’re inside of the solver or InferCtxtEvalExt::evaluate_root_goal if you’re outside of it.

source

fn evaluate_goal( &mut self, goal: Goal<'tcx, Predicate<'tcx>> ) -> Result<(bool, Certainty), NoSolution>

Recursively evaluates goal, returning whether any inference vars have been constrained and the certainty of the result.

source

fn compute_goal( &mut self, goal: Goal<'tcx, Predicate<'tcx>> ) -> QueryResult<'tcx>

source

fn compute_type_outlives_goal( &mut self, goal: Goal<'tcx, TypeOutlivesPredicate<'tcx>> ) -> QueryResult<'tcx>

source

fn compute_region_outlives_goal( &mut self, goal: Goal<'tcx, RegionOutlivesPredicate<'tcx>> ) -> QueryResult<'tcx>

source

fn compute_coerce_goal( &mut self, goal: Goal<'tcx, CoercePredicate<'tcx>> ) -> QueryResult<'tcx>

source

fn compute_subtype_goal( &mut self, goal: Goal<'tcx, SubtypePredicate<'tcx>> ) -> QueryResult<'tcx>

source

fn compute_closure_kind_goal( &mut self, goal: Goal<'tcx, (DefId, SubstsRef<'tcx>, ClosureKind)> ) -> QueryResult<'tcx>

source

fn compute_object_safe_goal(&mut self, trait_def_id: DefId) -> QueryResult<'tcx>

source

fn compute_well_formed_goal( &mut self, goal: Goal<'tcx, GenericArg<'tcx>> ) -> QueryResult<'tcx>

source

fn compute_alias_eq_goal( &mut self, goal: Goal<'tcx, (Term<'tcx>, Term<'tcx>)> ) -> QueryResult<'tcx>

source

fn compute_const_arg_has_type_goal( &mut self, goal: Goal<'tcx, (Const<'tcx>, Ty<'tcx>)> ) -> QueryResult<'tcx>

source§

impl<'tcx> EvalCtxt<'_, 'tcx>

source

fn evaluate_all( &mut self, goals: Vec<Goal<'tcx, Predicate<'tcx>>> ) -> Result<Certainty, NoSolution>

source

fn evaluate_all_and_make_canonical_response( &mut self, goals: Vec<Goal<'tcx, Predicate<'tcx>>> ) -> QueryResult<'tcx>

source

fn try_merge_responses( &mut self, responses: impl Iterator<Item = QueryResult<'tcx>> ) -> QueryResult<'tcx>

Trait Implementations§

source§

impl<'tcx> OverflowHandler<'tcx> for EvalCtxt<'_, 'tcx>

source§

fn search_graph(&mut self) -> &mut SearchGraph<'tcx>

source§

fn repeat_while_none<T>( &mut self, on_overflow: impl FnOnce(&mut Self) -> Result<T, NoSolution>, loop_body: impl FnMut(&mut Self) -> Option<Result<T, NoSolution>> ) -> Result<T, NoSolution>

Auto Trait Implementations§

§

impl<'a, 'tcx> !RefUnwindSafe for EvalCtxt<'a, 'tcx>

§

impl<'a, 'tcx> !Send for EvalCtxt<'a, 'tcx>

§

impl<'a, 'tcx> !Sync for EvalCtxt<'a, 'tcx>

§

impl<'a, 'tcx> Unpin for EvalCtxt<'a, 'tcx>where 'tcx: 'a,

§

impl<'a, 'tcx> !UnwindSafe for EvalCtxt<'a, 'tcx>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

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