Module rustc::infer::canonical [−][src]
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
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:
- a value T2 where each unbound inference variable has been replaced with a canonical variable;
- a map M (of type
CanonicalVarValues
) from those canonical variables back to the original.
We can then do queries using T2. These will give back constriants
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.
Re-exports
use infer::InferCtxt; |
use infer::InferOk; |
use infer::InferResult; |
use infer::RegionVariableOrigin; |
use infer::TypeVariableOrigin; |
use rustc_data_structures::indexed_vec::Idx; |
use serialize::UseSpecializedDecodable; |
use std::fmt::Debug; |
use std::ops::Index; |
use std::sync::atomic::Ordering; |
use syntax::codemap::Span; |
use traits::Obligation; |
use traits::ObligationCause; |
use traits::PredicateObligation; |
use ty; |
use ty::CanonicalVar; |
use ty::Lift; |
use ty::Region; |
use ty::Slice; |
use ty::Ty; |
use ty::TyCtxt; |
use ty::TypeFlags; |
use ty::subst::Kind; |
use ty::subst::UnpackedKind; |
use ty::fold::TypeFoldable; |
use ty::fold::TypeFolder; |
use rustc_data_structures::indexed_vec::IndexVec; |
use rustc_data_structures::fx::FxHashMap; |
Structs
Canonical |
[ Experimental ] A "canonicalized" type |
CanonicalVarInfo |
[ Experimental ] 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. |
CanonicalVarValues |
[ Experimental ] A set of values corresponding to the canonical variables from some
|
CanonicalVarValuesSubst |
[ Experimental ]
|
CanonicalizeAllFreeRegions |
[ Experimental ] If this flag is true, then all free regions will be replaced with
a canonical var. This is used to make queries as generic as
possible. For example, the query |
Canonicalizer |
[ Experimental ]
|
QueryResult |
[ Experimental ] After we execute a query with a canonicalized key, we get back a
|
Enums
CanonicalTyVarKind |
[ Experimental ] 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. |
CanonicalVarKind |
[ Experimental ] 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. |
Certainty |
[ Experimental ] Indicates whether or not we were able to prove the query to be true. |
Traits
Canonicalize |
[ Experimental ] Trait implemented by values that can be canonicalized. It mainly serves to identify the interning table we will use. |
Functions
substitute_value |
[ Experimental ] Substitute the values from |
Type Definitions
CanonicalVarInfos |
[ Experimental ]
|
QueryRegionConstraint |
[ Experimental ]
|