Module rustc_type_ir::canonical

source ·


  • 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.
  • 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.
  • A set of values corresponding to the canonical variables from some Canonical. You can give these values to canonical_value.instantiate to instantiate them into the canonical value at the right places.


  • 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.
  • 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.