Struct InferCtxt
pub struct InferCtxt<'db> {
pub interner: DbInterner<'db>,
pub inner: RefCell<InferCtxtInner<'db>>,
/* private fields */
}Fields§
§interner: DbInterner<'db>§inner: RefCell<InferCtxtInner<'db>>Implementations§
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn at<'a>( &'a self, cause: &'a ObligationCause, param_env: ParamEnv<'db>, ) -> At<'a, 'db>
pub fn fork(&self) -> InferCtxt<'db>
pub fn fork(&self) -> InferCtxt<'db>
Forks the inference context, creating a new inference context with the same inference variables in the same state. This can be used to “branch off” many tests from the same common state.
pub fn fork_with_typing_mode(
&self,
typing_mode: TypingMode<DbInterner<'db>>,
) -> InferCtxt<'db>
pub fn fork_with_typing_mode( &self, typing_mode: TypingMode<DbInterner<'db>>, ) -> InferCtxt<'db>
Forks the inference context, creating a new inference context with the same inference variables in the same state, except possibly changing the intercrate mode. This can be used to “branch off” many tests from the same common state. Used in negative coherence.
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn canonicalize_query<V>(
&self,
value: V,
query_state: &mut OriginalQueryValues<'db>,
) -> Canonical<DbInterner<'db>, V>where
V: TypeFoldable<DbInterner<'db>>,
pub fn canonicalize_query<V>(
&self,
value: V,
query_state: &mut OriginalQueryValues<'db>,
) -> Canonical<DbInterner<'db>, V>where
V: TypeFoldable<DbInterner<'db>>,
Canonicalizes a query value V. When we canonicalize a query,
we not only canonicalize unbound inference variables, but we
also replace all free regions whatsoever. So for example a
query like T: Trait<'static> would be canonicalized to
T: Trait<'?0>with a mapping M that maps '?0 to 'static.
To get a good understanding of what is happening here, check out the chapter in the rustc dev guide.
pub fn canonicalize_response<V>(
&self,
value: V,
) -> Canonical<DbInterner<'db>, V>where
V: TypeFoldable<DbInterner<'db>>,
pub fn canonicalize_response<V>(
&self,
value: V,
) -> Canonical<DbInterner<'db>, V>where
V: TypeFoldable<DbInterner<'db>>,
Canonicalizes a query response V. When we canonicalize a
query response, we only canonicalize unbound inference
variables, and we leave other free regions alone. So,
continuing with the example from canonicalize_query, if
there was an input query T: Trait<'static>, it would have
been canonicalized to
T: Trait<'?0>with a mapping M that maps '?0 to 'static. But if we found that there
exists only one possible impl of Trait, and it looks like
impl<T> Trait<'static> for T { .. }then we would prepare a query result R that (among other
things) includes a mapping to '?0 := 'static. When
canonicalizing this query result R, we would leave this
reference to 'static alone.
To get a good understanding of what is happening here, check out the chapter in the rustc dev guide.
pub fn canonicalize_user_type_annotation<V>(
&self,
value: V,
) -> Canonical<DbInterner<'db>, V>where
V: TypeFoldable<DbInterner<'db>>,
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn make_query_response_ignoring_pending_obligations<T>(
&self,
inference_vars: CanonicalVarValues<DbInterner<'db>>,
answer: T,
) -> Canonical<DbInterner<'db>, QueryResponse<'db, T>>where
T: TypeFoldable<DbInterner<'db>>,
pub fn make_query_response_ignoring_pending_obligations<T>(
&self,
inference_vars: CanonicalVarValues<DbInterner<'db>>,
answer: T,
) -> Canonical<DbInterner<'db>, QueryResponse<'db, T>>where
T: TypeFoldable<DbInterner<'db>>,
A version of make_canonicalized_query_response that does
not pack in obligations, for contexts that want to drop
pending obligations instead of treating them as an ambiguity (e.g.
typeck “probing” contexts).
If you DO want to keep track of pending obligations (which include all region obligations, so this includes all cases that care about regions) with this function, you have to do it yourself, by e.g., having them be a part of the answer.
pub fn instantiate_query_response_and_region_obligations<R>(
&self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
original_values: &OriginalQueryValues<'db>,
query_response: &Canonical<DbInterner<'db>, QueryResponse<'db, R>>,
) -> Result<InferOk<'db, R>, TypeError<DbInterner<'db>>>where
R: TypeFoldable<DbInterner<'db>>,
pub fn instantiate_query_response_and_region_obligations<R>(
&self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
original_values: &OriginalQueryValues<'db>,
query_response: &Canonical<DbInterner<'db>, QueryResponse<'db, R>>,
) -> Result<InferOk<'db, R>, TypeError<DbInterner<'db>>>where
R: TypeFoldable<DbInterner<'db>>,
Given the (canonicalized) result to a canonical query, instantiates the result so it can be used, plugging in the values from the canonical query. (Note that the result may have been ambiguous; you should check the certainty level of the query before applying this function.)
To get a good understanding of what is happening here, check out the chapter in the rustc dev guide.
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn instantiate_canonical<T>(
&self,
canonical: &Canonical<DbInterner<'db>, T>,
) -> (T, CanonicalVarValues<DbInterner<'db>>)where
T: TypeFoldable<DbInterner<'db>>,
pub fn instantiate_canonical<T>(
&self,
canonical: &Canonical<DbInterner<'db>, T>,
) -> (T, CanonicalVarValues<DbInterner<'db>>)where
T: TypeFoldable<DbInterner<'db>>,
Creates an instantiation S for the canonical value with fresh inference variables and placeholders then applies it to the canonical value. Returns both the instantiated result and the instantiation S.
This can be invoked as part of constructing an
inference context at the start of a query (see
InferCtxtBuilder::build_with_canonical). It basically
brings the canonical value “into scope” within your new infcx.
At the end of processing, the instantiation S (once canonicalized) then represents the values that you computed for each of the canonical inputs to your query.
pub fn instantiate_canonical_var(
&self,
cv_info: CanonicalVarKind<DbInterner<'db>>,
previous_var_values: &[GenericArg<'db>],
universe_map: impl Fn(UniverseIndex) -> UniverseIndex,
) -> GenericArg<'db>
pub fn instantiate_canonical_var( &self, cv_info: CanonicalVarKind<DbInterner<'db>>, previous_var_values: &[GenericArg<'db>], universe_map: impl Fn(UniverseIndex) -> UniverseIndex, ) -> GenericArg<'db>
Given the “info” about a canonical variable, creates a fresh variable for it. If this is an existentially quantified variable, then you’ll get a new inference variable; if it is a universally quantified variable, you get a placeholder.
FIXME(-Znext-solver): This is public because it’s used by the new trait solver which has a different canonicalization routine. We should somehow deduplicate all of this.
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
Insert a hidden type into the opaque type storage, making sure it hasn’t previously been defined. This does not emit any constraints and it’s the responsibility of the caller to make sure that the item bounds of the opaque are checked.
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn register_outlives_constraint( &self, _: OutlivesPredicate<DbInterner<'db>, GenericArg<'db>>, )
pub fn register_region_outlives_constraint( &self, _: OutlivesPredicate<DbInterner<'db>, Region<'db>>, )
pub fn register_type_outlives_constraint_inner(
&self,
obligation: TypeOutlivesConstraint<'db>,
)
pub fn register_type_outlives_constraint_inner( &self, obligation: TypeOutlivesConstraint<'db>, )
Registers that the given region obligation must be resolved
from within the scope of body_id. These regions are enqueued
and later processed by regionck, when full type information is
available (see region_obligations field for more
information).
pub fn register_type_outlives_constraint( &self, sup_type: Ty<'db>, sub_region: Region<'db>, )
pub fn register_region_assumption( &self, assumption: OutlivesPredicate<DbInterner<'db>, GenericArg<'db>>, )
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn instantiate_ty_var<R>(
&self,
relation: &mut R,
target_is_expected: bool,
target_vid: TyVid,
instantiation_variance: Variance,
source_ty: Ty<'db>,
) -> Result<(), TypeError<DbInterner<'db>>>where
R: PredicateEmittingRelation<InferCtxt<'db>>,
pub fn instantiate_ty_var<R>(
&self,
relation: &mut R,
target_is_expected: bool,
target_vid: TyVid,
instantiation_variance: Variance,
source_ty: Ty<'db>,
) -> Result<(), TypeError<DbInterner<'db>>>where
R: PredicateEmittingRelation<InferCtxt<'db>>,
The idea is that we should ensure that the type variable target_vid
is equal to, a subtype of, or a supertype of source_ty.
For this, we will instantiate target_vid with a generalized version
of source_ty. Generalization introduces other inference variables wherever
subtyping could occur. This also does the occurs checks, detecting whether
instantiating target_vid would result in a cyclic type. We eagerly error
in this case.
This is not expected to be used anywhere except for an implementation of
TypeRelation. Do not use this, and instead please use At::eq, for all
other usecases (i.e. setting the value of a type var).
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn enter_forall_and_leak_universe<T>(
&self,
binder: Binder<DbInterner<'db>, T>,
) -> Twhere
T: TypeFoldable<DbInterner<'db>> + Clone,
pub fn enter_forall_and_leak_universe<T>(
&self,
binder: Binder<DbInterner<'db>, T>,
) -> Twhere
T: TypeFoldable<DbInterner<'db>> + Clone,
Replaces all bound variables (lifetimes, types, and constants) bound by
binder with placeholder variables in a new universe. This means that the
new placeholders can only be named by inference variables created after
this method has been called.
This is the first step of checking subtyping when higher-ranked things are involved. For more details visit the relevant sections of the rustc dev guide.
fn enter_forall should be preferred over this method.
pub fn enter_forall<T, U>(
&self,
forall: Binder<DbInterner<'db>, T>,
f: impl FnOnce(T) -> U,
) -> Uwhere
T: TypeFoldable<DbInterner<'db>> + Clone,
pub fn enter_forall<T, U>(
&self,
forall: Binder<DbInterner<'db>, T>,
f: impl FnOnce(T) -> U,
) -> Uwhere
T: TypeFoldable<DbInterner<'db>> + Clone,
Replaces all bound variables (lifetimes, types, and constants) bound by
binder with placeholder variables in a new universe and then calls the
closure f with the instantiated value. The new placeholders can only be
named by inference variables created inside of the closure f or afterwards.
This is the first step of checking subtyping when higher-ranked things are involved. For more details visit the relevant sections of the rustc dev guide.
This method should be preferred over fn enter_forall_and_leak_universe.
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn fudge_inference_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
pub fn fudge_inference_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
This rather funky routine is used while processing expected
types. What happens here is that we want to propagate a
coercion through the return type of a fn to its
argument. Consider the type of Option::Some, which is
basically for<T> fn(T) -> Option<T>. So if we have an
expression Some(&[1, 2, 3]), and that has the expected type
Option<&[u32]>, we would like to type check &[1, 2, 3]
with the expectation of &[u32]. This will cause us to coerce
from &[u32; 3] to &[u32] and make the users life more
pleasant.
The way we do this is using fudge_inference_if_ok. What the
routine actually does is to start a snapshot and execute the
closure f. In our example above, what this closure will do
is to unify the expectation (Option<&[u32]>) with the actual
return type (Option<?T>, where ?T represents the variable
instantiated for T). This will cause ?T to be unified
with &?a [u32], where ?a is a fresh lifetime variable. The
input type (?T) is then returned by f().
At this point, fudge_inference_if_ok will normalize all type
variables, converting ?T to &?a [u32] and end the
snapshot. The problem is that we can’t just return this type
out, because it references the region variable ?a, and that
region variable was popped when we popped the snapshot.
So what we do is to keep a list (region_vars, in the code below)
of region variables created during the snapshot (here, ?a). We
fold the return value and replace any such regions with a new
region variable (e.g., ?b) and return the result (&?b [u32]).
This can then be used as the expectation for the fn argument.
The important point here is that, for soundness purposes, the
regions in question are not particularly important. We will
use the expected types to guide coercions, but we will still
type-check the resulting types from those coercions against
the actual types (?T, Option<?T>) – and remember that
after the snapshot is popped, the variable ?T is no longer
unified.
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn in_snapshot(&self) -> bool
pub fn num_open_snapshots(&self) -> usize
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
pub fn commit_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
Execute f and commit the bindings if closure f returns Ok(_).
pub fn probe<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&CombinedSnapshot) -> R,
pub fn probe<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&CombinedSnapshot) -> R,
Execute f then unroll any bindings it creates.
pub fn region_constraints_added_in_snapshot(
&self,
snapshot: &CombinedSnapshot,
) -> bool
pub fn region_constraints_added_in_snapshot( &self, snapshot: &CombinedSnapshot, ) -> bool
Scan the constraints produced since snapshot and check whether
we added any region constraints.
pub fn opaque_types_added_in_snapshot( &self, snapshot: &CombinedSnapshot, ) -> bool
§impl<'db> InferCtxt<'db>
impl<'db> InferCtxt<'db>
pub fn typing_mode(&self) -> TypingMode<DbInterner<'db>>
pub fn typing_mode_unchecked(&self) -> TypingMode<DbInterner<'db>>
pub fn predicate_may_hold(
&self,
obligation: &Obligation<'db, Predicate<'db>>,
) -> bool
pub fn predicate_may_hold( &self, obligation: &Obligation<'db, Predicate<'db>>, ) -> bool
Evaluates whether the predicate can be satisfied (by any means)
in the given ParamEnv.
pub fn predicate_may_hold_opaque_types_jank(
&self,
obligation: &Obligation<'db, Predicate<'db>>,
) -> bool
pub fn predicate_may_hold_opaque_types_jank( &self, obligation: &Obligation<'db, Predicate<'db>>, ) -> bool
See the comment on GeneralAutoderef::overloaded_deref_ty
for more details.
pub fn can_eq<T>(&self, param_env: ParamEnv<'db>, a: T, b: T) -> boolwhere
T: ToTrace<'db>,
pub fn goal_may_hold_opaque_types_jank(
&self,
goal: Goal<DbInterner<'db>, Predicate<'db>>,
) -> bool
pub fn goal_may_hold_opaque_types_jank( &self, goal: Goal<DbInterner<'db>, Predicate<'db>>, ) -> bool
See the comment on GeneralAutoderef::overloaded_deref_ty
for more details.
pub fn type_is_copy_modulo_regions( &self, param_env: ParamEnv<'db>, ty: Ty<'db>, ) -> bool
pub fn unresolved_variables(&self) -> Vec<Ty<'db>>
pub fn sub_regions(&self, a: Region<'db>, b: Region<'db>)
pub fn coerce_predicate(
&self,
cause: &ObligationCause,
param_env: ParamEnv<'db>,
predicate: Binder<DbInterner<'db>, CoercePredicate<DbInterner<'db>>>,
) -> Result<Result<InferOk<'db, ()>, TypeError<DbInterner<'db>>>, (TyVid, TyVid)>
pub fn coerce_predicate( &self, cause: &ObligationCause, param_env: ParamEnv<'db>, predicate: Binder<DbInterner<'db>, CoercePredicate<DbInterner<'db>>>, ) -> Result<Result<InferOk<'db, ()>, TypeError<DbInterner<'db>>>, (TyVid, TyVid)>
Processes a Coerce predicate from the fulfillment context.
This is NOT the preferred way to handle coercion, which is to
invoke FnCtxt::coerce or a similar method (see coercion.rs).
This method here is actually a fallback that winds up being
invoked when FnCtxt::coerce encounters unresolved type variables
and records a coercion predicate. Presently, this method is equivalent
to subtype_predicate – that is, “coercing” a to b winds up
actually requiring a <: b. This is of course a valid coercion,
but it’s not as flexible as FnCtxt::coerce would be.
(We may refactor this in the future, but there are a number of
practical obstacles. Among other things, FnCtxt::coerce presently
records adjustments that are required on the HIR in order to perform
the coercion, and we don’t currently have a way to manage that.)
pub fn subtype_predicate( &self, cause: &ObligationCause, param_env: ParamEnv<'db>, predicate: Binder<DbInterner<'db>, SubtypePredicate<DbInterner<'db>>>, ) -> Result<Result<InferOk<'db, ()>, TypeError<DbInterner<'db>>>, (TyVid, TyVid)>
pub fn region_outlives_predicate( &self, _cause: &ObligationCause, predicate: Binder<DbInterner<'db>, OutlivesPredicate<DbInterner<'db>, Region<'db>>>, )
pub fn num_ty_vars(&self) -> usize
pub fn num_ty_vars(&self) -> usize
Number of type variables created so far.
pub fn next_var_for_param(&self, id: GenericParamId) -> GenericArg<'db>
pub fn next_ty_var(&self) -> Ty<'db>
pub fn next_ty_vid(&self) -> TyVid
pub fn next_ty_var_with_origin(&self, origin: TypeVariableOrigin) -> Ty<'db>
pub fn next_ty_var_id_in_universe(&self, universe: UniverseIndex) -> TyVid
pub fn next_ty_var_in_universe(&self, universe: UniverseIndex) -> Ty<'db>
pub fn next_const_var(&self) -> Const<'db>
pub fn next_const_vid(&self) -> ConstVid
pub fn next_const_var_with_origin( &self, origin: ConstVariableOrigin, ) -> Const<'db>
pub fn next_const_var_in_universe(&self, universe: UniverseIndex) -> Const<'db>
pub fn next_int_var(&self) -> Ty<'db>
pub fn next_int_vid(&self) -> IntVid
pub fn next_float_var(&self) -> Ty<'db>
pub fn next_float_vid(&self) -> FloatVid
pub fn next_region_var(&self) -> Region<'db>
pub fn next_region_var(&self) -> Region<'db>
Creates a fresh region variable with the next available index. The variable will be created in the maximum universe created thus far, allowing it to name any region created thus far.
pub fn next_region_vid(&self) -> RegionVid
pub fn next_region_var_in_universe(
&self,
universe: UniverseIndex,
) -> Region<'db>
pub fn next_region_var_in_universe( &self, universe: UniverseIndex, ) -> Region<'db>
Creates a fresh region variable with the next available index
in the given universe; typically, you can use
next_region_var and just use the maximal universe.
pub fn next_term_var_of_kind(&self, term: Term<'db>) -> Term<'db>
pub fn universe_of_region(&self, r: Region<'db>) -> UniverseIndex
pub fn universe_of_region(&self, r: Region<'db>) -> UniverseIndex
Return the universe that the region r was created in. For
most regions (e.g., 'static, named regions from the user,
etc) this is the root universe U0. For inference variables or
placeholders, however, it will return the universe which they
are associated.
pub fn num_region_vars(&self) -> usize
pub fn num_region_vars(&self) -> usize
Number of region variables created so far.
pub fn next_nll_region_var(&self) -> Region<'db>
pub fn next_nll_region_var(&self) -> Region<'db>
Just a convenient wrapper of next_region_var for using during NLL.
pub fn next_nll_region_var_in_universe(
&self,
universe: UniverseIndex,
) -> Region<'db>
pub fn next_nll_region_var_in_universe( &self, universe: UniverseIndex, ) -> Region<'db>
Just a convenient wrapper of next_region_var for using during NLL.
pub fn fresh_args_for_item(&self, def_id: SolverDefId) -> GenericArgs<'db>
pub fn fresh_args_for_item(&self, def_id: SolverDefId) -> GenericArgs<'db>
Given a set of generics defined on a type or impl, returns the generic parameters mapping each type/region parameter to a fresh inference variable.
pub fn fill_rest_fresh_args(
&self,
def_id: SolverDefId,
first: impl IntoIterator<Item = GenericArg<'db>>,
) -> GenericArgs<'db>
pub fn fill_rest_fresh_args( &self, def_id: SolverDefId, first: impl IntoIterator<Item = GenericArg<'db>>, ) -> GenericArgs<'db>
Like fresh_args_for_item(), but first uses the args from first.
pub fn tainted_by_errors(&self) -> Option<ErrorGuaranteed>
pub fn tainted_by_errors(&self) -> Option<ErrorGuaranteed>
Returns true if errors have been reported since this infcx was
created. This is sometimes used as a heuristic to skip
reporting errors that often occur as a result of earlier
errors, but where it’s hard to be 100% sure (e.g., unresolved
inference variables, regionck errors).
pub fn set_tainted_by_errors(&self, e: ErrorGuaranteed)
pub fn set_tainted_by_errors(&self, e: ErrorGuaranteed)
Set the “tainted by errors” flag to true. We call this when we observe an error from a prior pass.
pub fn take_opaque_types( &self, ) -> Vec<(OpaqueTypeKey<DbInterner<'db>>, OpaqueHiddenType<'db>)>
pub fn clone_opaque_types( &self, ) -> Vec<(OpaqueTypeKey<DbInterner<'db>>, OpaqueHiddenType<'db>)>
pub fn can_define_opaque_ty(&self, id: impl Into<SolverDefId>) -> bool
pub fn probe_ty_var(&self, vid: TyVid) -> Result<Ty<'db>, UniverseIndex>
pub fn probe_ty_var(&self, vid: TyVid) -> Result<Ty<'db>, UniverseIndex>
If TyVar(vid) resolves to a type, return that type. Else, return the
universe index of TyVar(vid).
pub fn shallow_resolve(&self, ty: Ty<'db>) -> Ty<'db>
pub fn shallow_resolve_const(&self, ct: Const<'db>) -> Const<'db>
pub fn root_var(&self, var: TyVid) -> TyVid
pub fn root_const_var(&self, var: ConstVid) -> ConstVid
pub fn opportunistic_resolve_int_var(&self, vid: IntVid) -> Ty<'db>
pub fn opportunistic_resolve_int_var(&self, vid: IntVid) -> Ty<'db>
Resolves an int var to a rigid int type, if it was constrained to one, or else the root int var in the unification table.
pub fn resolve_int_var(&self, vid: IntVid) -> Option<Ty<'db>>
pub fn opportunistic_resolve_float_var(&self, vid: FloatVid) -> Ty<'db>
pub fn opportunistic_resolve_float_var(&self, vid: FloatVid) -> Ty<'db>
Resolves a float var to a rigid int type, if it was constrained to one, or else the root float var in the unification table.
pub fn resolve_float_var(&self, vid: FloatVid) -> Option<Ty<'db>>
pub fn resolve_vars_if_possible<T>(&self, value: T) -> Twhere
T: TypeFoldable<DbInterner<'db>>,
pub fn resolve_vars_if_possible<T>(&self, value: T) -> Twhere
T: TypeFoldable<DbInterner<'db>>,
Where possible, replaces type/const variables in
value with their final value. Note that region variables
are unaffected. If a type/const variable has not been unified, it
is left as is. This is an idempotent operation that does
not affect inference state in any way and so you can do it
at will.
pub fn probe_const_var( &self, vid: ConstVid, ) -> Result<Const<'db>, UniverseIndex>
pub fn instantiate_binder_with_fresh_vars<T>(
&self,
_lbrct: BoundRegionConversionTime,
value: Binder<DbInterner<'db>, T>,
) -> Twhere
T: TypeFoldable<DbInterner<'db>> + Clone,
pub fn closure_kind(&self, closure_ty: Ty<'db>) -> Option<ClosureKind>
pub fn closure_kind(&self, closure_ty: Ty<'db>) -> Option<ClosureKind>
Obtains the latest type of the given closure; this may be a
closure in the current function, in which case its
ClosureKind may not yet be known.
pub fn universe(&self) -> UniverseIndex
pub fn create_next_universe(&self) -> UniverseIndex
pub fn create_next_universe(&self) -> UniverseIndex
Creates and return a fresh universe that extends all previous
universes. Updates self.universe to that new universe.
pub fn is_ty_infer_var_definitely_unchanged<'a>(
&'a self,
) -> impl Fn(TyOrConstInferVar) + Captures<'db> + 'a
pub fn is_ty_infer_var_definitely_unchanged<'a>( &'a self, ) -> impl Fn(TyOrConstInferVar) + Captures<'db> + 'a
The returned function is used in a fast path. If it returns true the variable is
unchanged, false indicates that the status is unknown.
pub fn ty_or_const_infer_var_changed(
&self,
infer_var: TyOrConstInferVar,
) -> bool
pub fn ty_or_const_infer_var_changed( &self, infer_var: TyOrConstInferVar, ) -> bool
ty_or_const_infer_var_changed is equivalent to one of these two:
shallow_resolve(ty) != ty(wherety.kind = Infer(_))shallow_resolve(ct) != ct(wherect.kind = ConstKind::Infer(_))
However, ty_or_const_infer_var_changed is more efficient. It’s always
inlined, despite being large, because it has only two call sites that
are extremely hot (both in traits::fulfill’s checking of stalled_on
inference variables), and it handles both Ty and Const without
having to resort to storing full GenericArgs in stalled_on.
Trait Implementations§
§impl<'db> InferCtxtLike for InferCtxt<'db>
impl<'db> InferCtxtLike for InferCtxt<'db>
type Interner = DbInterner<'db>
type OpaqueTypeStorageEntries = OpaqueTypeStorageEntries
fn cx(&self) -> DbInterner<'db>
§fn next_trait_solver(&self) -> bool
fn next_trait_solver(&self) -> bool
fn typing_mode(&self) -> TypingMode<DbInterner<'db>>
fn universe(&self) -> UniverseIndex
fn create_next_universe(&self) -> UniverseIndex
fn universe_of_ty(&self, vid: TyVid) -> Option<UniverseIndex>
fn universe_of_lt(&self, lt: RegionVid) -> Option<UniverseIndex>
fn universe_of_ct(&self, ct: ConstVid) -> Option<UniverseIndex>
fn root_ty_var(&self, var: TyVid) -> TyVid
fn root_const_var(&self, var: ConstVid) -> ConstVid
fn opportunistic_resolve_ty_var(&self, vid: TyVid) -> Ty<'db>
fn opportunistic_resolve_int_var(&self, vid: IntVid) -> Ty<'db>
fn opportunistic_resolve_float_var(&self, vid: FloatVid) -> Ty<'db>
fn opportunistic_resolve_ct_var(&self, vid: ConstVid) -> Const<'db>
fn opportunistic_resolve_lt_var(&self, vid: RegionVid) -> Region<'db>
fn is_changed_arg( &self, arg: <<InferCtxt<'db> as InferCtxtLike>::Interner as Interner>::GenericArg, ) -> bool
fn next_ty_infer(&self) -> Ty<'db>
fn next_region_infer( &self, ) -> <<InferCtxt<'db> as InferCtxtLike>::Interner as Interner>::Region
fn next_const_infer(&self) -> Const<'db>
fn fresh_args_for_item(&self, def_id: SolverDefId) -> GenericArgs<'db>
fn instantiate_binder_with_infer<T>(
&self,
value: Binder<DbInterner<'db>, T>,
) -> Twhere
T: TypeFoldable<DbInterner<'db>> + Clone,
fn enter_forall<T, U>(
&self,
value: Binder<DbInterner<'db>, T>,
f: impl FnOnce(T) -> U,
) -> Uwhere
T: TypeFoldable<DbInterner<'db>> + Clone,
fn equate_ty_vids_raw(&self, a: TyVid, b: TyVid)
fn equate_int_vids_raw(&self, a: IntVid, b: IntVid)
fn equate_float_vids_raw(&self, a: FloatVid, b: FloatVid)
fn equate_const_vids_raw(&self, a: ConstVid, b: ConstVid)
fn instantiate_ty_var_raw<R>(
&self,
relation: &mut R,
target_is_expected: bool,
target_vid: TyVid,
instantiation_variance: Variance,
source_ty: Ty<'db>,
) -> Result<(), TypeError<DbInterner<'db>>>where
R: PredicateEmittingRelation<InferCtxt<'db>>,
fn instantiate_int_var_raw(&self, vid: IntVid, value: IntVarValue)
fn instantiate_float_var_raw(&self, vid: FloatVid, value: FloatVarValue)
fn instantiate_const_var_raw<R>(
&self,
relation: &mut R,
target_is_expected: bool,
target_vid: ConstVid,
source_ct: Const<'db>,
) -> Result<(), TypeError<DbInterner<'db>>>where
R: PredicateEmittingRelation<InferCtxt<'db>>,
fn set_tainted_by_errors(&self, e: ErrorGuaranteed)
fn shallow_resolve(&self, ty: Ty<'db>) -> Ty<'db>
fn shallow_resolve_const(&self, ct: Const<'db>) -> Const<'db>
fn resolve_vars_if_possible<T>(&self, value: T) -> Twhere
T: TypeFoldable<DbInterner<'db>>,
fn probe<T>(&self, probe: impl FnOnce() -> T) -> T
fn sub_regions(&self, sub: Region<'db>, sup: Region<'db>, _span: Span)
fn equate_regions(&self, a: Region<'db>, b: Region<'db>, _span: Span)
fn register_ty_outlives(&self, _ty: Ty<'db>, _r: Region<'db>, _span: Span)
fn opaque_types_storage_num_entries(&self) -> OpaqueTypeStorageEntries
fn clone_opaque_types_lookup_table( &self, ) -> Vec<(OpaqueTypeKey<DbInterner<'db>>, Ty<'db>)>
fn clone_duplicate_opaque_types( &self, ) -> Vec<(OpaqueTypeKey<DbInterner<'db>>, Ty<'db>)>
fn clone_opaque_types_added_since( &self, prev_entries: OpaqueTypeStorageEntries, ) -> Vec<(OpaqueTypeKey<DbInterner<'db>>, Ty<'db>)>
fn add_duplicate_opaque_type( &self, opaque_type_key: OpaqueTypeKey<DbInterner<'db>>, hidden_ty: Ty<'db>, _span: Span, )
fn reset_opaque_types(&self)
fn sub_unification_table_root_var(&self, var: TyVid) -> TyVid
fn sub_unify_ty_vids_raw(&self, a: TyVid, b: TyVid)
Auto Trait Implementations§
impl<'db> !Freeze for InferCtxt<'db>
impl<'db> !RefUnwindSafe for InferCtxt<'db>
impl<'db> Send for InferCtxt<'db>
impl<'db> !Sync for InferCtxt<'db>
impl<'db> Unpin for InferCtxt<'db>
impl<'db> !UnwindSafe for InferCtxt<'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
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<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