Module infer

Source

Re-exports§

pub use at::DefineOpaqueTypes;
pub use BoundRegionConversionTime::*;
pub use RegionVariableOrigin::*;
pub use SubregionOrigin::*;

Modules§

at
A nice interface for working with the infcx. The basic idea is to do infcx.at(cause, param_env), which sets the “cause” of the operation as well as the surrounding parameter environment. Then you can do something like .sub(a, b) or .eq(a, b) to create a subtype or equality relationship respectively. The first argument is always the “expected” output from the POV of diagnostics.
canonical
Canonicalization is the key to constructing a query in the middle of type inference. Ordinarily, it is not possible to store types from type inference in query keys, because they contain references to inference variables whose lifetimes are too short and so forth. Canonicalizing a value T1 using canonicalize_query produces two things:
context 🔒
free_regions 🔒
This module handles the relationships between “free regions”, i.e., lifetime parameters. Ordinarily, free regions are unrelated to one another, but they can be related via implied or explicit bounds. In that case, we track the bounds using the TransitiveRelation type, and use that to decide when one free region outlives another, and so forth.
freshen 🔒
Freshening is the process of replacing unknown variables with fresh types. The idea is that the type, after freshening, contains no inference variables but instead contains either a value for each variable or fresh “arbitrary” types wherever a variable would have been.
lexical_region_resolve 🔒
Lexical region resolution.
opaque_types 🔒
outlives
Various code related to computing outlives relations.
projection 🔒
region_constraints
See README.md.
relate
This module contains the definitions of most TypeRelations in the type system (except for some relations used for diagnostics and heuristics in the compiler). As well as the implementation of Relate for interned things (Ty/Const/etc).
resolve
snapshot 🔒
type_variable 🔒
unify_key 🔒

Structs§

FixupError
InferCtxt
InferCtxtBuilder
Used to configure inference contexts before their creation.
InferCtxtInner
This type contains all the things within InferCtxt that sit within a RefCell and are involved with taking/rolling back snapshots. Snapshot operations are hot enough that we want only one call to borrow_mut per call to start_snapshot and rollback_to.
InferOk
InferOk<'tcx, ()> is used a lot. It may seem like a useless wrapper around PredicateObligations<'tcx>, but it has one important property: because InferOk is marked with #[must_use], if you have a method InferCtxt::f that returns InferResult<'tcx, ()> and you call it with infcx.f()?; you’ll get a warning about the obligations being discarded without use, which is probably unintentional and has been a source of bugs in the past.
InferenceLiteralEraser 🔒
Replace {integer} with i32 and {float} with f64. Used only for diagnostics.
RegionObligation
See the region_obligations field for more information.
TypeFreshener
TypeTrace
The trace designates the path through inference that we took to encounter an error or subtyping constraint.

Enums§

BoundRegionConversionTime
Times when we replace bound regions with existentials:
IntVarValue
NllRegionVariableOrigin
RegionResolutionError
RegionVariableOrigin
Reasons to create a region inference variable.
StructurallyRelateAliases
Whether aliases should be related structurally or not. Used to adjust the behavior of generalization and combine.
SubregionOrigin
The origin of a r1 <= r2 constraint.
TyOrConstInferVar
Helper for InferCtxt::ty_or_const_infer_var_changed (see comment on that), currently used only for traits::fulfill’s list of stalled_on inference variables.
ValuePairs
See the error_reporting module for more details.

Traits§

PredicateEmittingRelation
TyCtxtInferExt

Type Aliases§

FixupResult 🔒
InferResult
UnificationTable 🔒

Derive Macros§

TypeFoldable
Derives TypeFoldable for the annotated struct or enum (union is not supported).
TypeVisitable
Derives TypeVisitable for the annotated struct or enum (union is not supported).