[][src]Module rustc::infer::canonical

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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:

We can then do queries using T2. These will give back constraints on the canonical variables which can be translated, using the map M, into constraints in our source context. This process of translating the results back is done by the instantiate_query_result method.

For a more detailed look at what is happening here, check out the chapter in the rustc guide.

Structs

CanonicalInternal

A "canonicalized" type V is one where all free inference variables have been rewritten to "canonical vars". These are numbered starting from 0 in order of first appearance.

CanonicalVarInfoInternal

Information about a canonical variable that is included with the canonical value. This is sufficient information for code to create a copy of the canonical value in some other inference context, with fresh inference variables replacing the canonical values.

CanonicalVarValuesInternal

A set of values corresponding to the canonical variables from some Canonical. You can give these values to canonical_value.substitute to substitute them into the canonical value at the right places.

OriginalQueryValuesInternal

When we canonicalize a value to form a query, we wind up replacing various parts of it with canonical variables. This struct stores those replaced bits to remember for when we process the query result.

QueryRegionConstraintsInternal
QueryResponseInternal

After we execute a query with a canonicalized key, we get back a Canonical<QueryResponse<..>>. You can use instantiate_query_result to access the data in this result.

Enums

CanonicalTyVarKindInternal

Rust actually has more than one category of type variables; notably, the type variables we create for literals (e.g., 22 or 22.) can only be instantiated with integral/float types (e.g., usize or f32). In order to faithfully reproduce a type, we need to know what set of types a given type variable can be unified with.

CanonicalVarKindInternal

Describes the "kind" of the canonical variable. This is a "kind" in the type-theory sense of the term -- i.e., a "meta" type system that analyzes type-like values.

CertaintyInternal

Indicates whether or not we were able to prove the query to be true.

Type Definitions

CanonicalVarInfosInternal
CanonicalizedInternal
CanonicalizedQueryResponseInternal
QueryOutlivesConstraintInternal