Crate rustc_type_ir

source ·

Re-exports§

Modules§

Structs§

  • Represents the unprojected term of a projection goal.
  • Represents the projection of an associated, opaque, or lazy-type-alias type.
  • Binder is a binder for higher-ranked lifetimes or types. It is part of the compiler’s representation for things like for<'a> Fn(&'a isize) (which would be represented by the type PolyTraitRef == Binder<I, TraitRef>). Note that when we instantiate, erase, or otherwise “discharge” these bound vars, we change the type from Binder<I, T> to just T (see e.g., liberate_late_bound_regions).
  • 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.
  • A closure can be modeled as a struct that looks like:
  • Struct returned by split().
  • Encodes that we have to coerce from the a type to the b type.
  • A const variable ID.
  • Similar to ClosureArgs; see the above documentation for more.
  • See docs for explanation of how each argument is used.
  • 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:
  • Similar to super::Binder except that it tracks early bound generics, i.e. struct Foo<T>(T) needs T instantiated immediately. This type primarily exists to avoid forgetting to call instantiate.
  • An effect variable ID.
  • A ProjectionPredicate for an ExistentialTraitRef.
  • An existential reference to a trait, where Self is erased. For example, the trait object Trait<'a, 'b, X, Y> is:
  • A floating-point (f32 or f64) type variable ID.
  • An integral (u32, i32, usize, etc.) type variable ID.
  • Used by the new solver. Unlike a ProjectionPredicate this can only be proven by actually normalizing alias.
  • A: 'region
  • This kind of predicate has no direct correspondent in the syntax, but it roughly corresponds to the syntactic forms:
  • A region variable ID.
  • Encodes that a must be a subtype of b. The a_is_expected flag indicates whether the a type is the type that we should label as “expected” when presenting user diagnostics.
  • A complete reference to a trait. These take numerous guises in syntax, but perhaps the most recognizable form is in a where-clause:
  • A type 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.
  • An unevaluated (potentially generic) constant used in the type-system.
  • “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.
  • A helper type that you can wrap round your own type in order to automatically cache the stable hash, type flags and debruijn index on creation and not recompute it whenever the information is needed. This is only done in incremental mode. You can also opt out of caching by using StableHash::ZERO for the hash, in which case the hash gets computed each time. This is useful if you have values that you intern but never (can?) use for stable hashing.

Enums§

  • 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.
  • Specifies how a trait object is represented.
  • An inference variable for a const, for use in const generics.
  • A placeholder for a type that hasn’t been inferred yet.
  • Polarity for a trait predicate. May either be negative or positive. Distinguished from ImplPolarity since we never compute goals with “reservation” level.
  • 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.
  • Defines the kinds of types used by the type system.

Constants§

Traits§

  • Imagine you have a function F: FnOnce(&[T]) -> R, plus an iterator iter that produces T items. You could combine them with f(&iter.collect::<Vec<_>>()), but this requires allocating memory for the Vec.
  • An Into-like trait that takes TyCtxt to perform interner-specific transformations.
  • A From-like trait that takes TyCtxt to perform interner-specific transformations.

Functions§