Struct rustc_trans::middle::ty::ctxtExperimental [-]  [+] [src]

pub struct ctxt<'tcx> {
    pub types: CommonTypes<'tcx>,
    pub sess: Session,
    pub def_map: RefCell<HashMap<u32, Def, FnvHasher>>,
    pub named_region_map: HashMap<u32, DefRegion, FnvHasher>,
    pub region_maps: RegionMaps,
    pub node_types: RefCell<HashMap<u32, &'tcx TyS<'tcx>, FnvHasher>>,
    pub item_substs: RefCell<HashMap<u32, ItemSubsts<'tcx>, FnvHasher>>,
    pub impl_or_trait_items: RefCell<HashMap<DefId, ImplOrTraitItem<'tcx>, FnvHasher>>,
    pub trait_item_def_ids: RefCell<HashMap<DefId, Rc<Vec<ImplOrTraitItemId>>, FnvHasher>>,
    pub trait_items_cache: RefCell<HashMap<DefId, Rc<Vec<ImplOrTraitItem<'tcx>>>, FnvHasher>>,
    pub impl_trait_cache: RefCell<HashMap<DefId, Option<Rc<TraitRef<'tcx>>>, FnvHasher>>,
    pub trait_refs: RefCell<HashMap<u32, Rc<TraitRef<'tcx>>, FnvHasher>>,
    pub trait_defs: RefCell<HashMap<DefId, Rc<TraitDef<'tcx>>, FnvHasher>>,
    pub object_cast_map: RefCell<HashMap<u32, Binder<Rc<TraitRef<'tcx>>>, FnvHasher>>,
    pub map: Map<'tcx>,
    pub intrinsic_defs: RefCell<HashMap<DefId, &'tcx TyS<'tcx>, FnvHasher>>,
    pub freevars: RefCell<HashMap<u32, Vec<Freevar>, FnvHasher>>,
    pub tcache: RefCell<HashMap<DefId, TypeScheme<'tcx>, FnvHasher>>,
    pub rcache: RefCell<HashMap<creader_cache_key, &'tcx TyS<'tcx>, FnvHasher>>,
    pub short_names_cache: RefCell<HashMap<&'tcx TyS<'tcx>, String, FnvHasher>>,
    pub tc_cache: RefCell<HashMap<&'tcx TyS<'tcx>, TypeContents, FnvHasher>>,
    pub ast_ty_to_ty_cache: RefCell<HashMap<u32, ast_ty_to_ty_cache_entry<'tcx>, FnvHasher>>,
    pub enum_var_cache: RefCell<HashMap<DefId, Rc<Vec<Rc<VariantInfo<'tcx>>>>, FnvHasher>>,
    pub ty_param_defs: RefCell<HashMap<u32, TypeParameterDef<'tcx>, FnvHasher>>,
    pub adjustments: RefCell<HashMap<u32, AutoAdjustment<'tcx>, FnvHasher>>,
    pub normalized_cache: RefCell<HashMap<&'tcx TyS<'tcx>, &'tcx TyS<'tcx>, FnvHasher>>,
    pub lang_items: LanguageItems,
    pub provided_method_sources: RefCell<HashMap<DefId, DefId, FnvHasher>>,
    pub struct_fields: RefCell<HashMap<DefId, Rc<Vec<field_ty>>, FnvHasher>>,
    pub item_variance_map: RefCell<HashMap<DefId, Rc<ItemVariances>, FnvHasher>>,
    pub variance_computed: Cell<bool>,
    pub destructor_for_type: RefCell<HashMap<DefId, DefId, FnvHasher>>,
    pub destructors: RefCell<HashSet<DefId, FnvHasher>>,
    pub trait_impls: RefCell<HashMap<DefId, Rc<RefCell<Vec<DefId>>>, FnvHasher>>,
    pub inherent_impls: RefCell<HashMap<DefId, Rc<Vec<DefId>>, FnvHasher>>,
    pub impl_items: RefCell<HashMap<DefId, Vec<ImplOrTraitItemId>, FnvHasher>>,
    pub used_unsafe: RefCell<HashSet<u32, FnvHasher>>,
    pub used_mut_nodes: RefCell<HashSet<u32, FnvHasher>>,
    pub populated_external_types: RefCell<HashSet<DefId, FnvHasher>>,
    pub populated_external_traits: RefCell<HashSet<DefId, FnvHasher>>,
    pub upvar_borrow_map: RefCell<HashMap<UpvarId, UpvarBorrow, FnvHasher>>,
    pub extern_const_statics: RefCell<HashMap<DefId, u32, FnvHasher>>,
    pub extern_const_variants: RefCell<HashMap<DefId, u32, FnvHasher>>,
    pub method_map: RefCell<HashMap<MethodCall, MethodCallee<'tcx>, FnvHasher>>,
    pub dependency_formats: RefCell<HashMap<CrateType, Vec<Option<LinkagePreference>>, FnvHasher>>,
    pub unboxed_closures: RefCell<HashMap<DefId, UnboxedClosure<'tcx>, FnvHasher>>,
    pub node_lint_levels: RefCell<HashMap<(u32, LintId), (Level, LintSource), FnvHasher>>,
    pub transmute_restrictions: RefCell<Vec<TransmuteRestriction<'tcx>>>,
    pub stability: RefCell<Index>,
    pub capture_modes: RefCell<HashMap<u32, CaptureClause, FnvHasher>>,
    pub associated_types: RefCell<HashMap<DefId, bool, FnvHasher>>,
    pub selection_cache: SelectionCache<'tcx>,
    pub repr_hint_cache: RefCell<HashMap<DefId, Rc<Vec<ReprAttr>>, FnvHasher>>,
    pub type_impls_copy_cache: RefCell<HashMap<&'tcx TyS<'tcx>, bool, RandomSipHasher>>,
    pub type_impls_sized_cache: RefCell<HashMap<&'tcx TyS<'tcx>, bool, RandomSipHasher>>,
    // some fields omitted
}

The data structure to keep track of all the information that typechecker generates so that so that it can be reused and doesn't have to be redone later on.

Fields

types

Common types, pre-interned for your convenience.

sess
def_map
named_region_map
region_maps
node_types

Stores the types for various nodes in the AST. Note that this table is not guaranteed to be populated until after typeck. See typeck::check::fn_ctxt for details.

item_substs

Stores the type parameters which were substituted to obtain the type of this node. This only applies to nodes that refer to entities parameterized by type parameters, such as generic fns, types, or other items.

impl_or_trait_items

Maps from a trait item to the trait item "descriptor"

trait_item_def_ids

Maps from a trait def-id to a list of the def-ids of its trait items

trait_items_cache

A cache for the trait_items() routine

impl_trait_cache
trait_refs
trait_defs
object_cast_map

Maps from node-id of a trait object cast (like foo as Box<Trait>) to the trait reference.

map
intrinsic_defs
freevars
tcache
rcache
short_names_cache
tc_cache
ast_ty_to_ty_cache
enum_var_cache
ty_param_defs
adjustments
normalized_cache
lang_items
provided_method_sources

A mapping of fake provided method def_ids to the default implementation

struct_fields
item_variance_map

Maps from def-id of a type or region parameter to its (inferred) variance.

variance_computed

True if the variance has been computed yet; false otherwise.

destructor_for_type

A mapping from the def ID of an enum or struct type to the def ID of the method that implements its destructor. If the type is not present in this map, it does not have a destructor. This map is populated during the coherence phase of typechecking.

destructors

A method will be in this list if and only if it is a destructor.

trait_impls

Maps a trait onto a list of impls of that trait.

inherent_impls

Maps a DefId of a type to a list of its inherent impls. Contains implementations of methods that are inherent to a type. Methods in these implementations don't need to be exported.

impl_items

Maps a DefId of an impl to a list of its items. Note that this contains all of the impls that we know about, including ones in other crates. It's not clear that this is the best way to do it.

used_unsafe

Set of used unsafe nodes (functions or blocks). Unsafe nodes not present in this set can be warned about.

used_mut_nodes

Set of nodes which mark locals as mutable which end up getting used at some point. Local variable definitions not in this set can be warned about.

populated_external_types

The set of external nominal types whose implementations have been read. This is used for lazy resolution of methods.

populated_external_traits

The set of external traits whose implementations have been read. This is used for lazy resolution of traits.

upvar_borrow_map

Borrows

extern_const_statics

These two caches are used by const_eval when decoding external statics and variants that are found.

extern_const_variants
method_map
dependency_formats
unboxed_closures

Records the type of each unboxed closure. The def ID is the ID of the expression defining the unboxed closure.

node_lint_levels
transmute_restrictions

The types that must be asserted to be the same size for transmute to be valid. We gather up these restrictions in the intrinsicck pass and check them in trans.

stability

Maps any item's def-id to its stability index.

capture_modes

Maps closures to their capture clauses.

associated_types

Maps def IDs to true if and only if they're associated types.

selection_cache

Caches the results of trait selection. This cache is used for things that do not have to do with the parameters in scope.

repr_hint_cache

Caches the representation hints for struct definitions.

type_impls_copy_cache

Caches whether types are known to impl Copy. Note that type parameters are never placed into this cache, because their results are dependent on the parameter environment.

type_impls_sized_cache

Caches whether types are known to impl Sized. Note that type parameters are never placed into this cache, because their results are dependent on the parameter environment.

Methods

impl<'tcx> ctxt<'tcx>

fn print_debug_stats(&self)

impl<'tcx> ctxt<'tcx>

fn mk_substs(&self, substs: Substs<'tcx>) -> &'tcx Substs<'tcx>

fn mk_bare_fn(&self, bare_fn: BareFnTy<'tcx>) -> &'tcx BareFnTy<'tcx>

fn mk_region(&self, region: Region) -> &'tcx Region

Trait Implementations

impl<'tcx> Typer<'tcx> for ctxt<'tcx>

fn tcx(&'a self) -> &'a ctxt<'tcx>

fn node_ty(&self, id: u32) -> &'tcx TyS<'tcx>

fn expr_ty_adjusted(&self, expr: &Expr) -> &'tcx TyS<'tcx>

fn node_method_ty(&self, method_call: MethodCall) -> Option<&'tcx TyS<'tcx>>

fn node_method_origin(&self, method_call: MethodCall) -> Option<MethodOrigin<'tcx>>

fn adjustments(&'a self) -> &'a RefCell<HashMap<u32, AutoAdjustment<'tcx>, FnvHasher>>

fn is_method_call(&self, id: u32) -> bool

fn temporary_scope(&self, rvalue_id: u32) -> Option<CodeExtent>

fn upvar_borrow(&self, upvar_id: UpvarId) -> UpvarBorrow

fn capture_mode(&self, closure_expr_id: u32) -> CaptureClause

fn unboxed_closures(&'a self) -> &'a RefCell<HashMap<DefId, UnboxedClosure<'tcx>, FnvHasher>>