[][src]Module rustc_middle::ty

Re-exports

pub use self::fold::TypeFoldable;
pub use self::fold::TypeFolder;
pub use self::fold::TypeVisitor;
pub use self::AssocItemContainer::*;
pub use self::BorrowKind::*;
pub use self::IntVarValue::*;
pub use self::Variance::*;
pub use self::sty::BoundRegion::*;
pub use self::sty::InferTy::*;
pub use self::sty::RegionKind::*;
pub use self::sty::TyKind::*;
pub use self::binding::BindingMode;
pub use self::binding::BindingMode::*;
pub use self::trait_def::TraitDef;
pub use self::query::queries;

Modules

_match
adjustment
binding
cast
codec
consts
context

Type context book-keeping.

diagnostics

Diagnostics related methods for TyS.

erase_regions
error
fast_reject
flags
fold

Generalized type folding mechanism. The setup is a bit convoluted but allows for convenient usage. Let T be an instance of some "foldable type" (one which implements TypeFoldable) and F be an instance of a "folder" (a type which implements TypeFolder). Then the setup is intended to be:

inhabitedness
instance
layout
list
normalize_erasing_regions

Methods for normalizing when you don't care about regions (and aren't doing type inference). If either of those things don't apply to you, use infcx.normalize(...).

outlives
print
query
relate

Generalized type relating mechanism.

steal
structural_impls

This module contains implements of the Lift and TypeFoldable traits for various types in the Rust compiler. Most are written by hand, though we've recently added some macros and proc-macros to help with the tedium.

sty

This module contains TyKind and its major components.

subst
tls
trait_def
util

Miscellaneous type-system utilities that are too small to deserve their own modules.

walk

An iterator over the type substructure. WARNING: this does not keep track of the region depth.

Structs

AdtDef

The definition of a user-defined type, e.g., a struct, enum, or union.

AdtFlags
AdtSizedConstraint
AssocItem
AssociatedItems

A list of ty::AssocItems in definition order that allows for efficient lookup by name.

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<TraitRef>). Note that when we instantiate, erase, or otherwise "discharge" these bound vars, we change the type from Binder<T> to just T (see e.g., liberate_late_bound_regions).

BoundTy
BoundVar
CReaderCacheKey
CanonicalUserTypeAnnotation
ClosureSubsts

A closure can be modeled as a struct that looks like:

Const

Typed constant value.

ConstInt

A type for representing any integer. Only used for printing.

ConstVid
ConstnessAnd
CrateInherentImpls

A map for the local crate mapping each type to a vector of its inherent impls. This is not meant to be used outside of coherence; rather, you should request the vector for a specific type via tcx.inherent_impls(def_id) so as to minimize your dependencies (constructing this map requires touching the entire crate).

CratePredicatesMap

The crate outlives map is computed during typeck and contains the outlives of every item in the local crate. You should not use it directly, because to do so will make your pass dependent on the HIR of every item in the local crate. Instead, use tcx.inferred_outlives_of() to get the outlives for a particular item.

CrateVariancesMap

The crate variances map is computed during typeck and contains the variance of every item in the local crate. You should not use it directly, because to do so will make your pass dependent on the HIR of every item in the local crate. Instead, use tcx.variances_of() to get the variance for a particular item.

CtxtInterners
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:

Destructor
EarlyBoundRegion
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:

FieldDef
FloatVarValue
FloatVid
FnSig

Signature of a function type, which we have arbitrarily decided to use to refer to the input/output types.

FreeRegion

A "free" region fr can be interpreted as "some region at least as big as the scope fr.scope".

FreeRegionInfo
GenSig
GeneratorInteriorTypeCause

Whenever a value may be live across a generator yield, the type of that value winds up in the GeneratorInteriorTypeCause struct. This struct adds additional information about such captured types that can be useful for diagnostics. In particular, it stores the span that caused a given type to be recorded, along with the scope that enclosed the value (which can be used to find the await that the value is live across).

GeneratorSubsts

Similar to ClosureSubsts; see the above documentation for more.

GenericParamCount
GenericParamDef
GenericPredicates

Bounds on generics.

Generics

Information about the formal type/lifetime parameters associated with an item or method. Analogous to hir::Generics.

GlobalCtxt
ImplHeader

The "header" of an impl is everything outside the body: a Self type, a trait ref (in the case of a trait impl), and a set of predicates (from the bounds / where-clauses).

Instance

A monomorphized InstanceDef.

InstantiatedPredicates

Represents the bounds declared on a particular set of type parameters. Should eventually be generalized into a flag list of where-clauses. You can obtain a InstantiatedPredicates list from a GenericPredicates by using the instantiate method. Note that this method reflects an important semantic invariant of InstantiatedPredicates: while the GenericPredicates are expressed in terms of the bound type parameters of the impl/trait/whatever, an InstantiatedPredicates instance represented a set of bounds for some particular instantiation, meaning that the generic parameters have been substituted with their values.

IntVid
List

A wrapper for slices with the additional invariant that the slice is interned and no other slice with the same contents can exist in the same context. This means we can use pointer for both equality comparisons and hashing.

OutlivesPredicate
ParamConst
ParamEnv

When type checking, we use the ParamEnv to track details about the set of where-clauses that are in scope at this particular point.

ParamEnvAnd
ParamTy
Placeholder

The "placeholder index" fully defines a placeholder region. Placeholder regions are identified by both a universe as well as a "bound-region" within that universe. The bound_region is basically a name -- distinct bound regions within the same universe are just two regions with an unknown relationship to one another.

Predicate
PredicateInner
ProjectionPredicate

This kind of predicate has no direct correspondent in the syntax, but it roughly corresponds to the syntactic forms:

ProjectionTy

Represents the projection of an associated type. In explicit UFCS form this would be written <T as Trait<..>>::N.

RegionVid
ReprFlags
ReprOptions

Represents the repr options provided by the user,

ResolvedOpaqueTy

All information necessary to validate and reveal an impl Trait.

ResolverOutputs
SubtypePredicate
SymbolName
TraitObjectVisitor

Collect al types that have an implicit 'static obligation that we could suggest '_ for.

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:

TyCtxt

The central data structure of the compiler. It stores references to the various arenas and also houses the results of the various compiler queries that have been performed. See the rustc dev guide for more details.

TyS
TyVid
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.

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

UpvarBorrow
UpvarId

Upvars do not get their own NodeId. Instead, we use the pair of the original var ID (that is, the root variable that is referenced by the upvar) and the ID of the closure expression.

UpvarPath
UserTypeAnnotationIndex
VariantDef

Definition of a variant -- a struct's fields or a enum variant.

VariantFlags
WithOptConstParam

A DefId which is potentially bundled with its corresponding generic parameter in case did is a const argument.

Enums

AdtKind
AssocItemContainer
AssocKind
BorrowKind
BoundRegion
BoundTyKind
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
GenericParamDefKind
ImplOverlapKind
ImplPolarity
InferConst

An inference variable for a const, for use in const generics.

InferTy
InstanceDef
IntVarValue
PredicateAtom
PredicateKind
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_mir::borrow_check module for more information.

TyKind

N.B., if you change this, you'll probably want to change the corresponding AST structure in librustc_ast/ast.rs as well.

UpvarCapture

Information describing the capture of an upvar. This is computed during typeck, specifically by regionck.

UpvarSubsts
UserType

A user-given type annotation attached to a constant. These arise from constants that are named via paths, like Foo::<A>::new and so forth.

Variance
VariantDiscr
Visibility

Constants

INNERMOST

Traits

DefIdTree
Lift

A trait implemented for all X<'a> types that can be safely and efficiently converted to X<'tcx> as long as they are part of the provided TyCtxt<'tcx>. This can be done, for example, for Ty<'tcx> or SubstsRef<'tcx> by looking them up in their respective interners.

ToPolyTraitRef
ToPredicate
WithConstness

Functions

is_impl_trait_defn

Yields the parent function's DefId if def_id is an impl Trait definition.

provide
suggest_constraining_type_param

Suggest restricting a type param with a new bound.

Type Definitions

Attributes
CanonicalPolyFnSig
CanonicalTy
CanonicalUserType

Canonicalized user type annotation.

CanonicalUserTypeAnnotations

Mapping of type annotation indices to canonical user type annotations.

PlaceholderConst
PlaceholderRegion
PlaceholderType
PolyExistentialProjection
PolyExistentialTraitRef
PolyFnSig
PolyGenSig
PolyOutlivesPredicate
PolyProjectionPredicate
PolyRegionOutlivesPredicate
PolySubtypePredicate
PolyTraitPredicate
PolyTraitRef
PolyTypeOutlivesPredicate
Region
RegionOutlivesPredicate
Ty
TypeOutlivesPredicate
UpvarCaptureMap
UpvarListMap