- data_structures
- elaborate
- error
- fast_reject
- inherent
- Set of traits which are used to emulate the inherent impls that are present in
rustc_middle.
It is customary to glob-import rustc_type_ir::inherent::* to bring all of these traits into
scope when programming in interner-agnostic settings, and to avoid importing any of these
directly elsewhere (i.e. specify the full path for an implementation downstream). - ir_print
- lang_items
- lift
- outlives
- The outlives relation
T: 'a or 'a: 'b. This code frequently
refers to rules defined in RFC 1214 (OutlivesFooBar), so see that
RFC for reference. - relate
- search_graph
- The search graph is responsible for caching and cycle detection in the trait
solver. Making sure that caching doesn’t result in soundness bugs or unstable
query results is very challenging and makes this one of the most-involved
self-contained components of the compiler.
- solve
- walk
- An iterator over the type substructure.
WARNING: this does not keep track of the region depth.
- TrivialTypeTraversalImpls
- Used for types that are
Copy and which do not care arena
allocated data (i.e., don’t need to be folded). - try_visit
- walk_visitable_list
- AliasTerm
- Represents the unprojected term of a projection goal.
- AliasTy
- Represents the projection of an associated, opaque, or lazy-type-alias type.
- Binder
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>).- BoundVar
- Canonical
- 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. - CanonicalParamEnvCacheEntry
- CanonicalQueryInput
- CanonicalVarValues
- 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. - ClosureArgs
- A closure can be modeled as a struct that looks like:
- ClosureArgsParts
- Struct returned by
split(). - CoercePredicate
- Encodes that we have to coerce from the
a type to the b type. - ConstVid
- A
const variable ID. - CoroutineArgs
- Similar to
ClosureArgs; see the above documentation for more. - CoroutineArgsParts
- CoroutineClosureArgs
- CoroutineClosureArgsParts
- See docs for explanation of how each argument is used.
- CoroutineClosureSignature
- CoroutineWitnessTypes
- DebruijnIndex
- 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:
- EarlyBinder
- Similar to
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. - EarlyBinderIter
- ExistentialProjection
- A
ProjectionPredicate for an ExistentialTraitRef. - ExistentialTraitRef
- An existential reference to a trait, where
Self is erased.
For example, the trait object Trait<'a, 'b, X, Y> is: - FlagComputation
- FloatVid
- A floating-point (
f32 or f64) type variable ID. - FnHeader
- FnSig
- FnSigTys
- GenSig
- HostEffectPredicate
- IntVid
- An integral (
u32, i32, usize, etc.) type variable ID. - IterIdentityCopied
- IterInstantiated
- IterInstantiatedCopied
- NormalizesTo
- Used by the new solver to normalize an alias. This always expects the
term to
be an unconstrained inference variable which is used as the output. - OpaqueTypeKey
- OutlivesPredicate
A: 'region- Placeholder
- The “placeholder index” fully defines a placeholder region, type, or const. Placeholders are
identified by both a universe, as well as a name residing within that universe. Distinct bound
regions/types/consts within the same universe simply have an unknown relationship to one
another.
- ProjectionPredicate
- This kind of predicate has no direct correspondent in the
syntax, but it roughly corresponds to the syntactic forms:
- RegionFolder
- Folds over the substructure of a type, visiting its component
types and all regions that occur free within it.
- RegionVid
- A region variable ID.
- SubtypePredicate
- 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. - TraitPredicate
- TraitRef
- A complete reference to a trait. These take numerous guises in syntax,
but perhaps the most recognizable form is in a where-clause:
- TyVid
- A type variable ID.
- TypeAndMut
- TypeFlags
- 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.
- UnevaluatedConst
- An unevaluated (potentially generic) constant used in the type-system.
- UniverseIndex
- “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. - UnsafeBinderInner
- ValidateBoundVars
- WithCachedTypeInfo
- 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.
- AliasRelationDirection
- AliasTermKind
- AliasTyKind
- BoundConstness
- BoundVarIndexKind
- Okay, we do something fun for
Bound types/regions/consts:
Specifically, we distinguish between canonically bound things and
for<> bound things. And, really, it comes down to caching during
canonicalization and instantiation. - CanonicalVarKind
- 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.
- ClauseKind
- A clause is something that can appear in where bounds or be inferred
by implied bounds.
- ClosureKind
- 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. - ConstKind
- Represents a constant in Rust.
- ExistentialPredicate
- FloatTy
- FloatVarValue
- GenericArgKind
- ImplPolarity
- InferConst
- An inference variable for a const, for use in const generics.
- InferTy
- A placeholder for a type that hasn’t been inferred yet.
- IntTy
- IntVarValue
- Movability
- The movability of a coroutine / closure literal:
whether a coroutine contains self-references, causing it to be
!Unpin. - Mutability
- PatternKind
- Pinnedness
- PredicateKind
- PredicatePolarity
- Polarity for a trait predicate. May either be negative or positive.
Distinguished from
ImplPolarity since we never compute goals with
“reservation” level. - RegionKind
- 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. - TermKind
- TyKind
- Defines the kinds of types used by the type system.
- TypingMode
- The current typing mode of an inference context. We unfortunately have some
slightly different typing rules depending on the current context. See the
doc comment for each variant for how and why they are used.
- UintTy
- Variance
- INNERMOST
- CollectAndApply
- 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. - FallibleTypeFolder
- This trait is implemented for every folding traversal. There is a fold
method defined for every type of interest. Each such method has a default
that does an “identity” fold.
- Flags
- InferCtxtLike
- Interner
- TypeFoldable
- This trait is implemented for every type that can be folded,
providing the skeleton of the traversal.
- TypeFolder
- This trait is implemented for every infallible folding traversal. There is
a fold method defined for every type of interest. Each such method has a
default that does an “identity” fold. Implementations of these methods
often fall back to a
super_fold_with method if the primary argument
doesn’t satisfy a particular condition. - TypeSuperFoldable
- TypeSuperVisitable
- TypeVisitable
- This trait is implemented for every type that can be visited,
providing the skeleton of the traversal.
- TypeVisitableExt
- TypeVisitor
- This trait is implemented for every visiting traversal. There is a visit
method defined for every type of interest. Each such method has a default
that recurses into the type’s fields in a non-custom fashion.
- Upcast
- An
Into-like trait that takes TyCtxt to perform interner-specific transformations. - UpcastFrom
- A
From-like trait that takes TyCtxt to perform interner-specific transformations. - VisitorResult
- Similar to the
Try trait, but also implemented for ().
- debug_bound_var
- fold_regions
- may_use_unstable_feature
- shift_region
- shift_vars