InferCtxt

Struct InferCtxt 

pub struct InferCtxt<'tcx> {
Show 15 fields pub tcx: TyCtxt<'tcx>, typing_mode: TypingMode<TyCtxt<'tcx>>, pub considering_regions: bool, pub in_hir_typeck: bool, skip_leak_check: bool, pub inner: RefCell<InferCtxtInner<'tcx>>, lexical_region_resolutions: RefCell<Option<LexicalRegionResolutions<'tcx>>>, pub selection_cache: Cache<(ParamEnv<'tcx>, TraitPredicate<TyCtxt<'tcx>>), Result<Option<SelectionCandidate<'tcx>>, SelectionError<'tcx>>>, pub evaluation_cache: Cache<(ParamEnv<'tcx>, Binder<TyCtxt<'tcx>, TraitPredicate<TyCtxt<'tcx>>>), EvaluationResult>, pub reported_trait_errors: RefCell<IndexMap<Span, (Vec<Goal<TyCtxt<'tcx>, Predicate<'tcx>>>, ErrorGuaranteed), BuildHasherDefault<FxHasher>>>, pub reported_signature_mismatch: RefCell<HashSet<(Span, Option<Span>), FxBuildHasher>>, tainted_by_errors: Cell<Option<ErrorGuaranteed>>, universe: Cell<UniverseIndex>, next_trait_solver: bool, pub obligation_inspector: Cell<Option<fn(&InferCtxt<'tcx>, &Obligation<'tcx, Predicate<'tcx>>, Result<Certainty, NoSolution>)>>,
}

Fields§

§tcx: TyCtxt<'tcx>§typing_mode: TypingMode<TyCtxt<'tcx>>§considering_regions: bool

Whether this inference context should care about region obligations in the root universe. Most notably, this is used during HIR typeck as region solving is left to borrowck instead.

§in_hir_typeck: bool

-Znext-solver: Whether this inference context is used by HIR typeck. If so, we need to make sure we don’t rely on region identity in the trait solver or when relating types. This is necessary as borrowck starts by replacing each occurrence of a free region with a unique inference variable. If HIR typeck ends up depending on two regions being equal we’d get unexpected mismatches between HIR typeck and MIR typeck, resulting in an ICE.

The trait solver sometimes depends on regions being identical. As a concrete example the trait solver ignores other candidates if one candidate exists without any constraints. The goal &'a u32: Equals<&'a u32> has no constraints right now. If we replace each occurrence of 'a with a unique region the goal now equates these regions. See the tests in trait-system-refactor-initiative#27 for concrete examples.

We handle this by uniquifying region when canonicalizing root goals during HIR typeck. This is still insufficient as inference variables may hide region variables, so e.g. dyn TwoSuper<?x, ?x>: Super<?x> may hold but MIR typeck could end up having to prove dyn TwoSuper<&'0 (), &'1 ()>: Super<&'2 ()> which is now ambiguous. Because of this we stash all successfully proven goals which reference inference variables and then reprove them after writeback.

§skip_leak_check: bool§inner: RefCell<InferCtxtInner<'tcx>>§lexical_region_resolutions: RefCell<Option<LexicalRegionResolutions<'tcx>>>§selection_cache: Cache<(ParamEnv<'tcx>, TraitPredicate<TyCtxt<'tcx>>), Result<Option<SelectionCandidate<'tcx>>, SelectionError<'tcx>>>

Caches the results of trait selection. This cache is used for things that depends on inference variables or placeholders.

§evaluation_cache: Cache<(ParamEnv<'tcx>, Binder<TyCtxt<'tcx>, TraitPredicate<TyCtxt<'tcx>>>), EvaluationResult>

Caches the results of trait evaluation. This cache is used for things that depends on inference variables or placeholders.

§reported_trait_errors: RefCell<IndexMap<Span, (Vec<Goal<TyCtxt<'tcx>, Predicate<'tcx>>>, ErrorGuaranteed), BuildHasherDefault<FxHasher>>>

The set of predicates on which errors have been reported, to avoid reporting the same error twice.

§reported_signature_mismatch: RefCell<HashSet<(Span, Option<Span>), FxBuildHasher>>§tainted_by_errors: Cell<Option<ErrorGuaranteed>>§universe: Cell<UniverseIndex>§next_trait_solver: bool§obligation_inspector: Cell<Option<fn(&InferCtxt<'tcx>, &Obligation<'tcx, Predicate<'tcx>>, Result<Certainty, NoSolution>)>>

Implementations§

§

impl<'tcx> InferCtxt<'tcx>

pub fn at<'a>( &'a self, cause: &'a ObligationCause<'tcx>, param_env: ParamEnv<'tcx>, ) -> At<'a, 'tcx>

pub fn fork(&self) -> InferCtxt<'tcx>

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<TyCtxt<'tcx>>, ) -> InferCtxt<'tcx>

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<'tcx> InferCtxt<'tcx>

pub fn canonicalize_query<V>( &self, value: ParamEnvAnd<'tcx, V>, query_state: &mut OriginalQueryValues<'tcx>, ) -> CanonicalQueryInput<TyCtxt<'tcx>, ParamEnvAnd<'tcx, V>>
where V: TypeFoldable<TyCtxt<'tcx>>,

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<TyCtxt<'tcx>, V>
where V: TypeFoldable<TyCtxt<'tcx>>,

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<TyCtxt<'tcx>, V>
where V: TypeFoldable<TyCtxt<'tcx>>,

§

impl<'tcx> InferCtxt<'tcx>

pub fn make_canonicalized_query_response<T>( &self, inference_vars: CanonicalVarValues<TyCtxt<'tcx>>, answer: T, fulfill_cx: &mut (dyn TraitEngine<'tcx, ScrubbedTraitError<'tcx>> + 'tcx), ) -> Result<&'tcx Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, T>>, NoSolution>
where T: Debug + TypeFoldable<TyCtxt<'tcx>>, Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, T>>: ArenaAllocatable<'tcx>,

This method is meant to be invoked as the final step of a canonical query implementation. It is given:

  • the instantiated variables inference_vars created from the query key
  • the result answer of the query
  • a fulfillment context fulfill_cx that may contain various obligations which have yet to be proven.

Given this, the function will process the obligations pending in fulfill_cx:

  • If all the obligations can be proven successfully, it will package up any resulting region obligations (extracted from infcx) along with the fully resolved value answer into a query result (which is then itself canonicalized).
  • If some obligations can be neither proven nor disproven, then the same thing happens, but the resulting query is marked as ambiguous.
  • Finally, if any of the obligations result in a hard error, then Err(NoSolution) is returned.

pub fn make_query_response_ignoring_pending_obligations<T>( &self, inference_vars: CanonicalVarValues<TyCtxt<'tcx>>, answer: T, ) -> Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, T>>
where T: Debug + TypeFoldable<TyCtxt<'tcx>>,

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<'tcx>, param_env: ParamEnv<'tcx>, original_values: &OriginalQueryValues<'tcx>, query_response: &Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, R>>, ) -> Result<InferOk<'tcx, R>, TypeError<TyCtxt<'tcx>>>
where R: Debug + TypeFoldable<TyCtxt<'tcx>>,

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.

pub fn instantiate_nll_query_response_and_region_obligations<R>( &self, cause: &ObligationCause<'tcx>, param_env: ParamEnv<'tcx>, original_values: &OriginalQueryValues<'tcx>, query_response: &Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, R>>, output_query_region_constraints: &mut QueryRegionConstraints<'tcx>, ) -> Result<InferOk<'tcx, R>, TypeError<TyCtxt<'tcx>>>
where R: Debug + TypeFoldable<TyCtxt<'tcx>>,

An alternative to instantiate_query_response_and_region_obligations that is more efficient for NLL. NLL is a bit more advanced in the “transition to chalk” than the rest of the compiler. During the NLL type check, all of the “processing” of types and things happens in queries – the NLL checker itself is only interested in the region obligations ('a: 'b or T: 'b) that come out of these queries, which it wants to convert into MIR-based constraints and solve. Therefore, it is most convenient for the NLL Type Checker to directly consume the QueryOutlivesConstraint values that arise from doing a query. This is contrast to other parts of the compiler, which would prefer for those QueryOutlivesConstraint to be converted into the older infcx-style constraints (e.g., calls to sub_regions or register_region_obligation).

Therefore, instantiate_nll_query_response_and_region_obligations performs the same basic operations as instantiate_query_response_and_region_obligations but it returns its result differently:

  • It creates an instantiation S that maps from the original query variables to the values computed in the query result. If any errors arise, they are propagated back as an Err result.
  • In the case of a successful instantiation, we will append QueryOutlivesConstraint values onto the output_query_region_constraints vector for the solver to use (if an error arises, some values may also be pushed, but they should be ignored).
  • It can happen (though it rarely does currently) that equating types and things will give rise to subobligations that must be processed. In this case, those subobligations are propagated back in the return value.
  • Finally, the query result (of type R) is propagated back, after applying the instantiation S.
§

impl<'tcx> InferCtxt<'tcx>

pub fn instantiate_canonical<T>( &self, span: Span, canonical: &Canonical<TyCtxt<'tcx>, T>, ) -> (T, CanonicalVarValues<TyCtxt<'tcx>>)
where T: TypeFoldable<TyCtxt<'tcx>>,

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, span: Span, kind: CanonicalVarKind<TyCtxt<'tcx>>, previous_var_values: &[GenericArg<'tcx>], universe_map: impl Fn(UniverseIndex) -> UniverseIndex, ) -> GenericArg<'tcx>

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<'tcx> InferCtxt<'tcx>

pub fn replace_opaque_types_with_inference_vars<T>( &self, value: T, body_id: LocalDefId, span: Span, param_env: ParamEnv<'tcx>, ) -> InferOk<'tcx, T>
where T: TypeFoldable<TyCtxt<'tcx>>,

This is a backwards compatibility hack to prevent breaking changes from lazy TAIT around RPIT handling.

pub fn handle_opaque_type( &self, a: Ty<'tcx>, b: Ty<'tcx>, span: Span, param_env: ParamEnv<'tcx>, ) -> Result<Vec<Goal<TyCtxt<'tcx>, Predicate<'tcx>>>, TypeError<TyCtxt<'tcx>>>

§

impl<'tcx> InferCtxt<'tcx>

pub fn register_hidden_type_in_storage( &self, opaque_type_key: OpaqueTypeKey<TyCtxt<'tcx>>, hidden_ty: ProvisionalHiddenType<'tcx>, ) -> Option<Ty<'tcx>>

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.

pub fn insert_hidden_type( &self, opaque_type_key: OpaqueTypeKey<TyCtxt<'tcx>>, span: Span, param_env: ParamEnv<'tcx>, hidden_ty: Ty<'tcx>, goals: &mut Vec<Goal<TyCtxt<'tcx>, Predicate<'tcx>>>, ) -> Result<(), TypeError<TyCtxt<'tcx>>>

Insert a hidden type into the opaque type storage, equating it with any previous entries if necessary.

This does not add the item bounds of the opaque as nested obligations. That is only necessary when normalizing the opaque itself, not when getting the opaque type constraints from somewhere else.

pub fn add_item_bounds_for_hidden_type( &self, def_id: DefId, args: &'tcx RawList<(), GenericArg<'tcx>>, param_env: ParamEnv<'tcx>, hidden_ty: Ty<'tcx>, goals: &mut Vec<Goal<TyCtxt<'tcx>, Predicate<'tcx>>>, )

§

impl<'tcx> InferCtxt<'tcx>

pub fn register_outlives_constraint( &self, _: OutlivesPredicate<TyCtxt<'tcx>, GenericArg<'tcx>>, cause: &ObligationCause<'tcx>, )

pub fn register_region_outlives_constraint( &self, _: OutlivesPredicate<TyCtxt<'tcx>, Region<'tcx>>, cause: &ObligationCause<'tcx>, )

pub fn register_type_outlives_constraint_inner( &self, obligation: TypeOutlivesConstraint<'tcx>, )

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<'tcx>, sub_region: Region<'tcx>, cause: &ObligationCause<'tcx>, )

pub fn take_registered_region_obligations( &self, ) -> Vec<TypeOutlivesConstraint<'tcx>>

Trait queries just want to pass back type obligations “as is”

pub fn clone_registered_region_obligations( &self, ) -> Vec<TypeOutlivesConstraint<'tcx>>

pub fn register_region_assumption( &self, assumption: OutlivesPredicate<TyCtxt<'tcx>, GenericArg<'tcx>>, )

pub fn take_registered_region_assumptions( &self, ) -> Vec<OutlivesPredicate<TyCtxt<'tcx>, GenericArg<'tcx>>>

pub fn process_registered_region_obligations( &self, outlives_env: &OutlivesEnvironment<'tcx>, deeply_normalize_ty: impl FnMut(Binder<TyCtxt<'tcx>, OutlivesPredicate<TyCtxt<'tcx>, Ty<'tcx>>>, SubregionOrigin<'tcx>) -> Result<Binder<TyCtxt<'tcx>, OutlivesPredicate<TyCtxt<'tcx>, Ty<'tcx>>>, NoSolution>, ) -> Result<(), (Binder<TyCtxt<'tcx>, OutlivesPredicate<TyCtxt<'tcx>, Ty<'tcx>>>, SubregionOrigin<'tcx>)>

Process the region obligations that must be proven (during regionck) for the given body_id, given information about the region bounds in scope and so forth.

See the region_obligations field of InferCtxt for some comments about how this function fits into the overall expected flow of the inferencer. The key point is that it is invoked after all type-inference variables have been bound – right before lexical region resolution.

§

impl<'tcx> InferCtxt<'tcx>

pub fn resolve_regions_with_normalize( &self, outlives_env: &OutlivesEnvironment<'tcx>, deeply_normalize_ty: impl Fn(Binder<TyCtxt<'tcx>, OutlivesPredicate<TyCtxt<'tcx>, Ty<'tcx>>>, SubregionOrigin<'tcx>) -> Result<Binder<TyCtxt<'tcx>, OutlivesPredicate<TyCtxt<'tcx>, Ty<'tcx>>>, NoSolution>, ) -> Vec<RegionResolutionError<'tcx>>

Process the region constraints and return any errors that result. After this, no more unification operations should be done – or the compiler will panic – but it is legal to use resolve_vars_if_possible as well as fully_resolve.

If you are in a crate that has access to rustc_trait_selection, then it’s probably better to use resolve_regions, which knows how to normalize registered region obligations.

pub fn take_and_reset_region_constraints(&self) -> RegionConstraintData<'tcx>

Obtains (and clears) the current set of region constraints. The inference context is still usable: further unifications will simply add new constraints.

This method is not meant to be used with normal lexical region resolution. Rather, it is used in the NLL mode as a kind of interim hack: basically we run normal type-check and generate region constraints as normal, but then we take them and translate them into the form that the NLL solver understands. See the NLL module for mode details.

pub fn with_region_constraints<R>( &self, op: impl FnOnce(&RegionConstraintData<'tcx>) -> R, ) -> R

Gives temporary access to the region constraint data.

§

impl<'tcx> InferCtxt<'tcx>

pub fn projection_term_to_infer( &self, param_env: ParamEnv<'tcx>, alias_term: AliasTerm<TyCtxt<'tcx>>, cause: ObligationCause<'tcx>, recursion_depth: usize, obligations: &mut ThinVec<Obligation<'tcx, Predicate<'tcx>>>, ) -> Term<'tcx>

Instead of normalizing an associated type projection, this function generates an inference variable and registers an obligation that this inference variable must be the result of the given projection. This allows us to proceed with projections while they cannot be resolved yet due to missing information or simply due to the lack of access to the trait resolution machinery.

§

impl<'tcx> InferCtxt<'tcx>

pub fn instantiate_ty_var<R>( &self, relation: &mut R, target_is_expected: bool, target_vid: TyVid, instantiation_variance: Variance, source_ty: Ty<'tcx>, ) -> Result<(), TypeError<TyCtxt<'tcx>>>

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<'tcx> InferCtxt<'tcx>

pub fn enter_forall_and_leak_universe<T>( &self, binder: Binder<TyCtxt<'tcx>, T>, ) -> T
where T: TypeFoldable<TyCtxt<'tcx>>,

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<TyCtxt<'tcx>, T>, f: impl FnOnce(T) -> U, ) -> U
where T: TypeFoldable<TyCtxt<'tcx>>,

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.

pub fn leak_check( &self, outer_universe: UniverseIndex, only_consider_snapshot: Option<&CombinedSnapshot<'tcx>>, ) -> Result<(), TypeError<TyCtxt<'tcx>>>

See RegionConstraintCollector::leak_check. We only check placeholder leaking into outer_universe, i.e. placeholders which cannot be named by that universe.

§

impl<'tcx> InferCtxt<'tcx>

pub fn fudge_inference_if_ok<T, E, F>(&self, f: F) -> Result<T, E>
where F: FnOnce() -> Result<T, E>, T: TypeFoldable<TyCtxt<'tcx>>, E: Debug,

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<'tcx> InferCtxt<'tcx>

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>
where F: FnOnce(&CombinedSnapshot<'tcx>) -> Result<T, E>,

Execute f and commit the bindings if closure f returns Ok(_).

pub fn probe<R, F>(&self, f: F) -> R
where F: FnOnce(&CombinedSnapshot<'tcx>) -> R,

Execute f then unroll any bindings it creates.

pub fn region_constraints_added_in_snapshot( &self, snapshot: &CombinedSnapshot<'tcx>, ) -> 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<'tcx>, ) -> bool

§

impl<'tcx> InferCtxt<'tcx>

pub fn dcx(&self) -> DiagCtxtHandle<'_>

pub fn next_trait_solver(&self) -> bool

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

pub fn freshen<T>(&self, t: T) -> T
where T: TypeFoldable<TyCtxt<'tcx>>,

pub fn type_var_origin(&self, vid: TyVid) -> TypeVariableOrigin

Returns the origin of the type variable identified by vid.

No attempt is made to resolve vid to its root variable.

pub fn const_var_origin(&self, vid: ConstVid) -> Option<ConstVariableOrigin>

Returns the origin of the const variable identified by vid

pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'tcx>

pub fn unresolved_variables(&self) -> Vec<Ty<'tcx>>

pub fn sub_regions( &self, origin: SubregionOrigin<'tcx>, a: Region<'tcx>, b: Region<'tcx>, )

pub fn coerce_predicate( &self, cause: &ObligationCause<'tcx>, param_env: ParamEnv<'tcx>, predicate: Binder<TyCtxt<'tcx>, CoercePredicate<TyCtxt<'tcx>>>, ) -> Result<Result<InferOk<'tcx, ()>, TypeError<TyCtxt<'tcx>>>, (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<'tcx>, param_env: ParamEnv<'tcx>, predicate: Binder<TyCtxt<'tcx>, SubtypePredicate<TyCtxt<'tcx>>>, ) -> Result<Result<InferOk<'tcx, ()>, TypeError<TyCtxt<'tcx>>>, (TyVid, TyVid)>

pub fn num_ty_vars(&self) -> usize

Number of type variables created so far.

pub fn next_ty_vid(&self, span: Span) -> TyVid

pub fn next_ty_vid_with_origin(&self, origin: TypeVariableOrigin) -> TyVid

pub fn next_ty_vid_in_universe( &self, span: Span, universe: UniverseIndex, ) -> TyVid

pub fn next_ty_var(&self, span: Span) -> Ty<'tcx>

pub fn next_ty_var_with_origin(&self, origin: TypeVariableOrigin) -> Ty<'tcx>

pub fn next_ty_var_in_universe( &self, span: Span, universe: UniverseIndex, ) -> Ty<'tcx>

pub fn next_const_var(&self, span: Span) -> Const<'tcx>

pub fn next_const_var_with_origin( &self, origin: ConstVariableOrigin, ) -> Const<'tcx>

pub fn next_const_var_in_universe( &self, span: Span, universe: UniverseIndex, ) -> Const<'tcx>

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

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

pub fn next_region_var(&self, origin: RegionVariableOrigin) -> Region<'tcx>

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_var_in_universe( &self, origin: RegionVariableOrigin, universe: UniverseIndex, ) -> Region<'tcx>

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<'tcx>, span: Span) -> Term<'tcx>

pub fn universe_of_region(&self, r: Region<'tcx>) -> 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

Number of region variables created so far.

pub fn next_nll_region_var( &self, origin: NllRegionVariableOrigin, ) -> Region<'tcx>

Just a convenient wrapper of next_region_var for using during NLL.

pub fn next_nll_region_var_in_universe( &self, origin: NllRegionVariableOrigin, universe: UniverseIndex, ) -> Region<'tcx>

Just a convenient wrapper of next_region_var for using during NLL.

pub fn var_for_def( &self, span: Span, param: &GenericParamDef, ) -> GenericArg<'tcx>

pub fn fresh_args_for_item( &self, span: Span, def_id: DefId, ) -> &'tcx RawList<(), GenericArg<'tcx>>

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 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)

Set the “tainted by errors” flag to true. We call this when we observe an error from a prior pass.

pub fn region_var_origin(&self, vid: RegionVid) -> RegionVariableOrigin

pub fn get_region_var_infos(&self) -> IndexVec<RegionVid, RegionVariableInfo>

Clone the list of variable regions. This is used only during NLL processing to put the set of region variables into the NLL region context.

pub fn has_opaque_types_in_storage(&self) -> bool

pub fn take_opaque_types( &self, ) -> Vec<(OpaqueTypeKey<TyCtxt<'tcx>>, ProvisionalHiddenType<'tcx>)>

pub fn clone_opaque_types( &self, ) -> Vec<(OpaqueTypeKey<TyCtxt<'tcx>>, ProvisionalHiddenType<'tcx>)>

pub fn has_opaques_with_sub_unified_hidden_type(&self, ty_vid: TyVid) -> bool

pub fn opaques_with_sub_unified_hidden_type( &self, ty_vid: TyVid, ) -> Vec<AliasTy<TyCtxt<'tcx>>>

Searches for an opaque type key whose hidden type is related to ty_vid.

This only checks for a subtype relation, it does not require equality.

pub fn can_define_opaque_ty(&self, id: impl Into<DefId>) -> bool

pub fn push_hir_typeck_potentially_region_dependent_goal( &self, goal: Obligation<'tcx, Predicate<'tcx>>, )

pub fn take_hir_typeck_potentially_region_dependent_goals( &self, ) -> Vec<Obligation<'tcx, Predicate<'tcx>>>

pub fn ty_to_string(&self, t: Ty<'tcx>) -> String

pub fn probe_ty_var(&self, vid: TyVid) -> Result<Ty<'tcx>, 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<'tcx>) -> Ty<'tcx>

pub fn shallow_resolve_const(&self, ct: Const<'tcx>) -> Const<'tcx>

pub fn shallow_resolve_term(&self, term: Term<'tcx>) -> Term<'tcx>

pub fn root_var(&self, var: TyVid) -> TyVid

pub fn sub_unify_ty_vids_raw(&self, a: TyVid, b: TyVid)

pub fn sub_unification_table_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<'tcx>

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 opportunistic_resolve_float_var(&self, vid: FloatVid) -> Ty<'tcx>

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_vars_if_possible<T>(&self, value: T) -> T
where T: TypeFoldable<TyCtxt<'tcx>>,

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 resolve_numeric_literals_with_default<T>(&self, value: T) -> T
where T: TypeFoldable<TyCtxt<'tcx>>,

pub fn probe_const_var( &self, vid: ConstVid, ) -> Result<Const<'tcx>, UniverseIndex>

pub fn fully_resolve<T>(&self, value: T) -> Result<T, FixupError>
where T: TypeFoldable<TyCtxt<'tcx>>,

Attempts to resolve all type/region/const variables in value. Region inference must have been run already (e.g., by calling resolve_regions_and_report_errors). If some variable was never unified, an Err results.

This method is idempotent, but it not typically not invoked except during the writeback phase.

pub fn instantiate_binder_with_fresh_vars<T>( &self, span: Span, lbrct: BoundRegionConversionTime, value: Binder<TyCtxt<'tcx>, T>, ) -> T
where T: TypeFoldable<TyCtxt<'tcx>> + Copy,

pub fn closure_kind(&self, closure_ty: Ty<'tcx>) -> 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

Creates and return a fresh universe that extends all previous universes. Updates self.universe to that new universe.

pub fn typing_env(&self, param_env: ParamEnv<'tcx>) -> TypingEnv<'tcx>

Extract ty::TypingMode of this inference context to get a TypingEnv which contains the necessary information to use the trait system without using canonicalization or carrying this inference context around.

pub fn pseudo_canonicalize_query<V>( &self, param_env: ParamEnv<'tcx>, value: V, ) -> PseudoCanonicalInput<'tcx, V>
where V: TypeVisitable<TyCtxt<'tcx>>,

Similar to Self::canonicalize_query, except that it returns a PseudoCanonicalInput and requires both the value and the param_env to not contain any inference variables or placeholders.

pub fn is_ty_infer_var_definitely_unchanged(&self) -> impl Fn(TyOrConstInferVar)

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

ty_or_const_infer_var_changed is equivalent to one of these two:

  • shallow_resolve(ty) != ty (where ty.kind = ty::Infer(_))
  • shallow_resolve(ct) != ct (where ct.kind = ty::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 ty::Const without having to resort to storing full GenericArgs in stalled_on.

pub fn attach_obligation_inspector( &self, inspector: fn(&InferCtxt<'tcx>, &Obligation<'tcx, Predicate<'tcx>>, Result<Certainty, NoSolution>), )

Attach a callback to be invoked on each root obligation evaluated in the new trait solver.

§

impl<'tcx> InferCtxt<'tcx>

pub fn find_block_span(&self, block: &'tcx Block<'tcx>) -> Span

Given a hir::Block, get the span of its last expression or statement, peeling off any inner blocks.

pub fn find_block_span_from_hir_id(&self, hir_id: HirId) -> Span

Given a hir::HirId for a block (or an expr of a block), get the span of its last expression or statement, peeling off any inner blocks.

Trait Implementations§

Source§

impl<'a, 'tcx> From<&'a InferCtxt<'tcx>> for &'a SolverDelegate<'tcx>

Source§

fn from(infcx: &'a InferCtxt<'tcx>) -> Self

Converts to this type from the input type.
Source§

impl<'tcx> InferCtxtErrorExt<'tcx> for InferCtxt<'tcx>

Source§

fn err_ctxt(&self) -> TypeErrCtxt<'_, 'tcx>

Creates a TypeErrCtxt for emitting various inference errors. During typeck, use FnCtxt::err_ctxt instead.

Source§

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

Source§

fn type_implements_trait( &self, trait_def_id: DefId, params: impl IntoIterator<Item: Into<GenericArg<'tcx>>>, param_env: ParamEnv<'tcx>, ) -> EvaluationResult

Check whether a ty implements given trait(trait_def_id) without side-effects.

The inputs are:

  • the def-id of the trait
  • the type parameters of the trait, including the self-type
  • the parameter environment

Invokes evaluate_obligation, so in the event that evaluating Ty: Trait causes overflow, EvaluatedToAmbigStackDependent will be returned.

type_implements_trait is a convenience function for simple cases like

let copy_trait = infcx.tcx.require_lang_item(LangItem::Copy, span);
let implements_copy = infcx.type_implements_trait(copy_trait, [ty], param_env)
.must_apply_modulo_regions();

In most cases you should instead create an Obligation and check whether it holds via evaluate_obligation or one of its helper functions like predicate_must_hold_modulo_regions, because it properly handles higher ranked traits and it is more convenient and safer when your params are inside a Binder.

Source§

fn type_implements_trait_shallow( &self, trait_def_id: DefId, ty: Ty<'tcx>, param_env: ParamEnv<'tcx>, ) -> Option<Vec<FulfillmentError<'tcx>>>

Returns Some if a type implements a trait shallowly, without side-effects, along with any errors that would have been reported upon further obligation processing.

  • If this returns Some([]), then the trait holds modulo regions.
  • If this returns Some([errors..]), then the trait has an impl for the self type, but some nested obligations do not hold.
  • If this returns None, no implementation that applies could be found.
Source§

fn can_eq<T: ToTrace<'tcx>>( &self, param_env: ParamEnv<'tcx>, a: T, b: T, ) -> bool

Source§

fn type_is_copy_modulo_regions( &self, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, ) -> bool

Source§

fn type_is_clone_modulo_regions( &self, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, ) -> bool

Source§

fn type_is_use_cloned_modulo_regions( &self, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, ) -> bool

Source§

fn type_is_sized_modulo_regions( &self, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, ) -> bool

Source§

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

Source§

fn implied_bounds_tys<Tys: IntoIterator<Item = Ty<'tcx>>>( &self, body_id: LocalDefId, param_env: ParamEnv<'tcx>, tys: Tys, disable_implied_bounds_hack: bool, ) -> impl Iterator<Item = OutlivesBound<'tcx>>

Do NOT call this directly. You probably want to construct a OutlivesEnvironment instead if you’re interested in the implied bounds for a given signature.

Source§

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

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_may_hold_opaque_types_jank( &self, obligation: &PredicateObligation<'tcx>, ) -> bool

See the comment on OpaqueTypesJank for more details.

Source§

fn goal_may_hold_opaque_types_jank( &self, goal: Goal<'tcx, Predicate<'tcx>>, ) -> bool

See the comment on OpaqueTypesJank for more details.

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.

§

impl<'tcx> InferCtxtLike for InferCtxt<'tcx>

§

type Interner = TyCtxt<'tcx>

§

type OpaqueTypeStorageEntries = OpaqueTypeStorageEntries

§

fn cx(&self) -> TyCtxt<'tcx>

§

fn next_trait_solver(&self) -> bool

Whether the new trait solver is enabled. This only exists because rustc shares code between the new and old trait solvers; for all other users, this should always be true. If this is unknowingly false and you try to use the new trait solver, things will break badly.
§

fn typing_mode(&self) -> TypingMode<TyCtxt<'tcx>>

§

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 sub_unification_table_root_var(&self, var: TyVid) -> TyVid

§

fn root_const_var(&self, var: ConstVid) -> ConstVid

§

fn opportunistic_resolve_ty_var(&self, vid: TyVid) -> Ty<'tcx>

§

fn opportunistic_resolve_int_var(&self, vid: IntVid) -> Ty<'tcx>

§

fn opportunistic_resolve_float_var(&self, vid: FloatVid) -> Ty<'tcx>

§

fn opportunistic_resolve_ct_var(&self, vid: ConstVid) -> Const<'tcx>

§

fn opportunistic_resolve_lt_var(&self, vid: RegionVid) -> Region<'tcx>

§

fn is_changed_arg(&self, arg: GenericArg<'tcx>) -> bool

§

fn next_region_infer(&self) -> Region<'tcx>

§

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

§

fn next_const_infer(&self) -> Const<'tcx>

§

fn fresh_args_for_item( &self, def_id: DefId, ) -> &'tcx RawList<(), GenericArg<'tcx>>

§

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

§

fn enter_forall<T, U>( &self, value: Binder<TyCtxt<'tcx>, T>, f: impl FnOnce(T) -> U, ) -> U
where T: TypeFoldable<TyCtxt<'tcx>>,

§

fn equate_ty_vids_raw(&self, a: TyVid, b: TyVid)

§

fn sub_unify_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<'tcx>, ) -> Result<(), TypeError<TyCtxt<'tcx>>>

§

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<'tcx>, ) -> Result<(), TypeError<TyCtxt<'tcx>>>

§

fn set_tainted_by_errors(&self, e: ErrorGuaranteed)

§

fn shallow_resolve(&self, ty: Ty<'tcx>) -> Ty<'tcx>

§

fn shallow_resolve_const(&self, ct: Const<'tcx>) -> Const<'tcx>

§

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

§

fn probe<T>(&self, probe: impl FnOnce() -> T) -> T

§

fn sub_regions(&self, sub: Region<'tcx>, sup: Region<'tcx>, span: Span)

§

fn equate_regions(&self, a: Region<'tcx>, b: Region<'tcx>, span: Span)

§

fn register_ty_outlives(&self, ty: Ty<'tcx>, r: Region<'tcx>, span: Span)

§

fn opaque_types_storage_num_entries(&self) -> OpaqueTypeStorageEntries

§

fn clone_opaque_types_lookup_table( &self, ) -> Vec<(OpaqueTypeKey<TyCtxt<'tcx>>, Ty<'tcx>)>

§

fn clone_duplicate_opaque_types( &self, ) -> Vec<(OpaqueTypeKey<TyCtxt<'tcx>>, Ty<'tcx>)>

§

fn clone_opaque_types_added_since( &self, prev_entries: OpaqueTypeStorageEntries, ) -> Vec<(OpaqueTypeKey<TyCtxt<'tcx>>, Ty<'tcx>)>

§

fn opaques_with_sub_unified_hidden_type( &self, ty: TyVid, ) -> Vec<AliasTy<TyCtxt<'tcx>>>

§

fn register_hidden_type_in_storage( &self, opaque_type_key: OpaqueTypeKey<TyCtxt<'tcx>>, hidden_ty: Ty<'tcx>, span: Span, ) -> Option<Ty<'tcx>>

§

fn add_duplicate_opaque_type( &self, opaque_type_key: OpaqueTypeKey<TyCtxt<'tcx>>, hidden_ty: Ty<'tcx>, span: Span, )

§

fn reset_opaque_types(&self)

Source§

impl<'tcx> InferCtxtProofTreeExt<'tcx> for InferCtxt<'tcx>

Source§

fn visit_proof_tree<V: ProofTreeVisitor<'tcx>>( &self, goal: Goal<'tcx, Predicate<'tcx>>, visitor: &mut V, ) -> V::Result

Source§

fn visit_proof_tree_at_depth<V: ProofTreeVisitor<'tcx>>( &self, goal: Goal<'tcx, Predicate<'tcx>>, depth: usize, visitor: &mut V, ) -> V::Result

Source§

impl<'tcx> InferCtxtRegionExt<'tcx> for InferCtxt<'tcx>

Source§

fn resolve_regions( &self, body_id: LocalDefId, param_env: ParamEnv<'tcx>, assumed_wf_tys: impl IntoIterator<Item = Ty<'tcx>>, ) -> Vec<RegionResolutionError<'tcx>>

Resolve regions, using the deep normalizer to normalize any type-outlives obligations in the process. This is in rustc_trait_selection because we need to normalize.

Prefer this method over resolve_regions_with_normalize, unless you are doing something specific for normalization.

This function assumes that all infer variables are already constrained.

Source§

fn resolve_regions_with_outlives_env( &self, outlives_env: &OutlivesEnvironment<'tcx>, ) -> Vec<RegionResolutionError<'tcx>>

Don’t call this directly unless you know what you’re doing.

Source§

impl<'tcx> InferCtxtSelectExt<'tcx> for InferCtxt<'tcx>

Source§

fn select_in_new_trait_solver( &self, obligation: &TraitObligation<'tcx>, ) -> SelectionResult<'tcx, Selection<'tcx>>

Do not use this directly. This is called from crate::traits::SelectionContext::select.

§

impl<'cx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'tcx>

§

fn push_sub_region_constraint( &mut self, origin: SubregionOrigin<'tcx>, a: Region<'tcx>, b: Region<'tcx>, _constraint_category: ConstraintCategory<'tcx>, )

§

fn push_verify( &mut self, origin: SubregionOrigin<'tcx>, kind: GenericKind<'tcx>, a: Region<'tcx>, bound: VerifyBound<'tcx>, )

Auto Trait Implementations§

§

impl<'tcx> DynSend for InferCtxt<'tcx>

§

impl<'tcx> !DynSync for InferCtxt<'tcx>

§

impl<'tcx> !Freeze for InferCtxt<'tcx>

§

impl<'tcx> !RefUnwindSafe for InferCtxt<'tcx>

§

impl<'tcx> !Send for InferCtxt<'tcx>

§

impl<'tcx> !Sync for InferCtxt<'tcx>

§

impl<'tcx> Unpin for InferCtxt<'tcx>

§

impl<'tcx> !UnwindSafe for InferCtxt<'tcx>

Blanket Implementations§

Source§

impl<T> Aligned for T

Source§

const ALIGN: Alignment

Alignment of Self.
Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T, R> CollectAndApply<T, R> for T

Source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

Source§

type Output = R

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<P> IntoQueryParam<P> for P

Source§

impl<T> MaybeResult<T> for T

Source§

type Error = !

Source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

Source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<Infcx> RelateExt for Infcx
where Infcx: InferCtxtLike,

Source§

fn relate<T>( &self, param_env: <<Infcx as InferCtxtLike>::Interner as Interner>::ParamEnv, lhs: T, variance: Variance, rhs: T, span: <<Infcx as InferCtxtLike>::Interner as Interner>::Span, ) -> Result<Vec<Goal<<Infcx as InferCtxtLike>::Interner, <<Infcx as InferCtxtLike>::Interner as Interner>::Predicate>>, TypeError<<Infcx as InferCtxtLike>::Interner>>
where T: Relate<<Infcx as InferCtxtLike>::Interner>,

Source§

fn eq_structurally_relating_aliases<T>( &self, param_env: <<Infcx as InferCtxtLike>::Interner as Interner>::ParamEnv, lhs: T, rhs: T, span: <<Infcx as InferCtxtLike>::Interner as Interner>::Span, ) -> Result<Vec<Goal<<Infcx as InferCtxtLike>::Interner, <<Infcx as InferCtxtLike>::Interner as Interner>::Predicate>>, TypeError<<Infcx as InferCtxtLike>::Interner>>
where T: Relate<<Infcx as InferCtxtLike>::Interner>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

Source§

fn upcast(self, interner: I) -> U

Source§

impl<I, T> UpcastFrom<I, T> for T

Source§

fn upcast_from(from: T, _tcx: I) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

Source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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: 800 bytes