Crate rustc_type_ir

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 const variable ID.
  • A De Bruijn index is a standard means of representing regions (and perhaps later types) in a higher-ranked setting. In particular, imagine a type like this:
  • An effect variable ID.
  • Flags that we track on types. These flags are propagated upwards through the type during type construction, so that we can quickly check whether the type has various kinds of types in it without recursing over the type itself.
  • “Universes” are used during type- and trait-checking in the presence of for<..> binders to control what sets of names are visible. Universes are arranged into a tree: the root universe contains names that are always visible. Each child then adds a new set of names that are visible, in addition to those of its parent. We say that the child universe “extends” the parent universe with new names.


  • 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.
  • A clause is something that can appear in where bounds or be inferred by implied bounds.
  • Represents the various closure traits in the language. This will determine the type of the environment (self, in the desugaring) argument that the closure expects.
  • Represents a constant in Rust.
  • An inference variable for a const, for use in const generics.
  • Representation of regions. Note that the NLL checker uses a distinct representation of regions. For this reason, it internally replaces all the regions with inference variables – the index of the variable is then used to index into internal NLL data structures. See rustc_const_eval::borrow_check module for more information.