Module rustc::ty[][src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Re-exports

pub use self::Variance::*;
pub use self::AssociatedItemContainer::*;
pub use self::BorrowKind::*;
pub use self::IntVarValue::*;
pub use self::fold::TypeFoldable;
use hir::map as hir_map;
use hir::FreevarMap;
use hir::TraitMap;
use hir::def::Def;
use hir::def::CtorKind;
use hir::def::ExportMap;
use hir::def_id::CrateNum;
use hir::def_id::DefId;
use hir::def_id::LocalDefId;
use hir::def_id::CRATE_DEF_INDEX;
use hir::def_id::LOCAL_CRATE;
use hir::map::DefPathData;
use hir::svh::Svh;
use ich::Fingerprint;
use ich::StableHashingContext;
use infer::canonical::Canonical;
use infer::canonical::Canonicalize;
use middle::lang_items::FnTraitLangItem;
use middle::lang_items::FnMutTraitLangItem;
use middle::lang_items::FnOnceTraitLangItem;
use middle::privacy::AccessLevels;
use middle::resolve_lifetime::ObjectLifetimeDefault;
use mir::Mir;
use mir::interpret::GlobalId;
use mir::GeneratorLayout;
use session::CrateDisambiguator;
use traits;
use traits::Reveal;
use ty;
use ty::subst::Subst;
use ty::subst::Substs;
use ty::util::IntTypeExt;
use ty::util::Discr;
use ty::walk::TypeWalker;
use util::captures::Captures;
use util::nodemap::NodeSet;
use util::nodemap::NodeSet;
use util::nodemap::DefIdMap;
use util::nodemap::DefIdMap;
use util::nodemap::FxHashMap;
use util::nodemap::FxHashMap;
use arena::SyncDroplessArena;
use serialize;
use serialize::Encodable;
use serialize::Encoder;
use std::cell::RefCell;
use std::cmp;
use std::cmp::Ordering;
use std::fmt;
use std::hash::Hash;
use std::hash::Hasher;
use std::ops::Deref;
use rustc_data_structures::sync;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::sync::ParallelIterator;
use rustc_data_structures::sync::par_iter;
use std::slice;
use std::vec::IntoIter;
use std::mem;
use syntax::ast;
use syntax::ast::DUMMY_NODE_ID;
use syntax::ast::Name;
use syntax::ast::Ident;
use syntax::ast::NodeId;
use syntax::attr;
use syntax::ext::hygiene::Mark;
use syntax::symbol::Symbol;
use syntax::symbol::LocalInternedString;
use syntax::symbol::InternedString;
use syntax_pos::DUMMY_SP;
use syntax_pos::Span;
use rustc_data_structures::accumulate_vec::IntoIter as AccIntoIter;
use rustc_data_structures::stable_hasher::StableHasher;
use rustc_data_structures::stable_hasher::StableHasherResult;
use rustc_data_structures::stable_hasher::HashStable;
use hir;
pub use self::sty::BoundRegion::*;
pub use self::sty::InferTy::*;
pub use self::sty::RegionKind::*;
pub use self::sty::TypeVariants::*;
pub use self::binding::BindingMode;
pub use self::binding::BindingMode::*;
pub use self::trait_def::TraitDef;
pub use self::query::queries;

Modules

_match [
Experimental
]
adjustment [
Experimental
]
binding [
Experimental
]
cast [
Experimental
]
codec [
Experimental
]
context [
Experimental
]

type context book-keeping

erase_regions [
Experimental
]
error [
Experimental
]
fast_reject [
Experimental
]
flags [
Experimental
]
fold [
Experimental
]

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 [
Experimental
]
instance [
Experimental
]
item_path [
Experimental
]
layout [
Experimental
]
outlives [
Experimental
]
query [
Experimental
]
relate [
Experimental
]

Generalized type relating mechanism. A type relation R relates a pair of values (A, B). A and B are usually types or regions but can be other things. Examples of type relations are subtyping, type equality, etc.

steal [
Experimental
]
structural_impls [
Experimental
]

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 (e.g., BraceStructLiftImpl!) to help with the tedium.

sty [
Experimental
]

This module contains TypeVariants and its major components

subst [
Experimental
]
tls [
Experimental
]
trait_def [
Experimental
]
util [
Experimental
]

misc. type-system utilities too small to deserve their own file

walk [
Experimental
]

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

wf [
Experimental
]

Structs

AdtDef [
Experimental
]

The definition of an abstract data type - a struct or enum.

AdtFlags [
Experimental
]
AllArenas [
Experimental
]
AssociatedItem [
Experimental
]
Binder [
Experimental
]

Binder is a binder for higher-ranked lifetimes. 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 skolemize, instantiate, erase, or otherwise "discharge" these bound regions, we change the type from Binder<T> to just T (see e.g. liberate_late_bound_regions).

CReaderCacheKey [
Experimental
]
CanonicalVar [
Experimental
]
ClosureSubsts [
Experimental
]

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

ClosureUpvar [
Experimental
]
Const [
Experimental
]

Typed constant value.

CrateAnalysis [
Experimental
]

The complete set of all analyses described in this module. This is produced by the driver and fed to codegen and later passes.

CrateInherentImpls [
Experimental
]

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 [
Experimental
]

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 [
Experimental
]

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.

DebruijnIndex [
Experimental
]
Destructor [
Experimental
]
EarlyBoundRegion [
Experimental
]
ExistentialProjection [
Experimental
]

A ProjectionPredicate for an ExistentialTraitRef.

ExistentialTraitRef [
Experimental
]

An existential reference to a trait, where Self is erased. For example, the trait object Trait<'a, 'b, X, Y> is:

FieldDef [
Experimental
]
FloatVarValue [
Experimental
]
FloatVid [
Experimental
]
FnSig [
Experimental
]

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

FreeRegion [
Experimental
]

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

GenSig [
Experimental
]
GeneratorSubsts [
Experimental
]
GenericParamCount [
Experimental
]
GenericParamDef [
Experimental
]
GenericPredicates [
Experimental
]

Bounds on generics.

Generics [
Experimental
]

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

GlobalArenas [
Experimental
]

Internal storage

ImplHeader [
Experimental
]

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 [
Experimental
]
InstantiatedPredicates [
Experimental
]

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 [
Experimental
]
OutlivesPredicate [
Experimental
]
ParamEnv [
Experimental
]

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 [
Experimental
]
ParamTy [
Experimental
]
ProjectionPredicate [
Experimental
]

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

ProjectionTy [
Experimental
]

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

RegionVid [
Experimental
]
ReprFlags [
Experimental
]
ReprOptions [
Experimental
]

Represents the repr options provided by the user,

Resolutions [
Experimental
]
Slice [
Experimental
]

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.

SubtypePredicate [
Experimental
]
SymbolName [
Experimental
]
TraitPredicate [
Experimental
]
TraitRef [
Experimental
]

A complete reference to a trait. These take numerous guises in syntax, but perhaps the most recognizable form is in a where clause:

TyCtxt [
Experimental
]

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 guide for more details.

TyS [
Experimental
]
TyVid [
Experimental
]
TypeAndMut [
Experimental
]
TypeFlags [
Experimental
]
TypeckTables [
Experimental
]
UniverseIndex [
Experimental
]

"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. But when you enter into some subuniverse, then it may add names that are only visible within that subtree (but it can still name the names of its ancestor universes).

UpvarBorrow [
Experimental
]
UpvarId [
Experimental
]

Upvars do not get their own node-id. 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.

VariantDef [
Experimental
]

Enums

AdtKind [
Experimental
]
AssociatedItemContainer [
Experimental
]
AssociatedKind [
Experimental
]
Attributes [
Experimental
]
BorrowKind [
Experimental
]
BoundRegion [
Experimental
]
ClosureKind [
Experimental
]

Represents the various closure traits in the Rust language. This will determine the type of the environment (self, in the desuaring) argument that the closure expects.

ExistentialPredicate [
Experimental
]
GenericParamDefKind [
Experimental
]
InferTy [
Experimental
]
InstanceDef [
Experimental
]
IntVarValue [
Experimental
]
Predicate [
Experimental
]
RegionKind [
Experimental
]

Representation of regions.

TypeVariants [
Experimental
]

NB: If you change this, you'll probably want to change the corresponding AST structure in libsyntax/ast.rs as well.

UpvarCapture [
Experimental
]

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

UpvarSubsts [
Experimental
]
Variance [
Experimental
]
VariantDiscr [
Experimental
]
Visibility [
Experimental
]

Constants

INNERMOST [
Experimental
]

Traits

DefIdTree [
Experimental
]
Lift [
Experimental
]

A trait implemented for all X<'a> types which 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 &'tcx Substs<'tcx> by looking them up in their respective interners.

ToPolyTraitRef [
Experimental
]
ToPredicate [
Experimental
]

Functions

adt_sized_constraint [
Experimental
]

Calculates the Sized-constraint.

associated_item [
Experimental
]
associated_item_def_ids [
Experimental
]
crate_disambiguator [
Experimental
]
crate_hash [
Experimental
]
def_span [
Experimental
]
instance_def_size_estimate [
Experimental
]
keep_local [
Experimental
]
original_crate_name [
Experimental
]
param_env [
Experimental
]

See ParamEnv struct def'n for details.

provide [
Experimental
]
trait_of_item [
Experimental
]

If the given def ID describes an item belonging to a trait, return the ID of the trait that the trait item belongs to. Otherwise, return None.

Type Definitions

CanonicalTy [
Experimental
]
PolyExistentialProjection [
Experimental
]
PolyExistentialTraitRef [
Experimental
]
PolyFnSig [
Experimental
]
PolyGenSig [
Experimental
]
PolyOutlivesPredicate [
Experimental
]
PolyProjectionPredicate [
Experimental
]
PolyRegionOutlivesPredicate [
Experimental
]
PolySubtypePredicate [
Experimental
]
PolyTraitPredicate [
Experimental
]
PolyTraitRef [
Experimental
]
PolyTypeOutlivesPredicate [
Experimental
]
Region [
Experimental
]
RegionOutlivesPredicate [
Experimental
]
Ty [
Experimental
]
TypeOutlivesPredicate [
Experimental
]
UpvarCaptureMap [
Experimental
]

Foreign Types

OpaqueSliceContents [
Experimental
]

A dummy type used to force Slice to by unsized without requiring fat pointers