Struct rustc_typeck::middle::ty::ctxt
[−]
[src]
pub struct ctxt<'tcx> {
pub types: CommonTypes<'tcx>,
pub sess: Session,
pub def_map: RefCell<HashMap<u32, PathResolution, DefaultState<FnvHasher>>>,
pub named_region_map: HashMap<u32, DefRegion, DefaultState<FnvHasher>>,
pub region_maps: RegionMaps,
pub item_substs: RefCell<HashMap<u32, ItemSubsts<'tcx>, DefaultState<FnvHasher>>>,
pub impl_or_trait_items: RefCell<HashMap<DefId, ImplOrTraitItem<'tcx>, DefaultState<FnvHasher>>>,
pub trait_item_def_ids: RefCell<HashMap<DefId, Rc<Vec<ImplOrTraitItemId>>, DefaultState<FnvHasher>>>,
pub trait_items_cache: RefCell<HashMap<DefId, Rc<Vec<ImplOrTraitItem<'tcx>>>, DefaultState<FnvHasher>>>,
pub impl_trait_cache: RefCell<HashMap<DefId, Option<TraitRef<'tcx>>, DefaultState<FnvHasher>>>,
pub impl_trait_refs: RefCell<HashMap<u32, TraitRef<'tcx>, DefaultState<FnvHasher>>>,
pub trait_defs: RefCell<HashMap<DefId, &'tcx TraitDef<'tcx>, DefaultState<FnvHasher>>>,
pub predicates: RefCell<HashMap<DefId, GenericPredicates<'tcx>, DefaultState<FnvHasher>>>,
pub super_predicates: RefCell<HashMap<DefId, GenericPredicates<'tcx>, DefaultState<FnvHasher>>>,
pub object_cast_map: RefCell<HashMap<u32, Binder<TraitRef<'tcx>>, DefaultState<FnvHasher>>>,
pub map: Map<'tcx>,
pub freevars: RefCell<HashMap<u32, Vec<Freevar>, DefaultState<FnvHasher>>>,
pub tcache: RefCell<HashMap<DefId, TypeScheme<'tcx>, DefaultState<FnvHasher>>>,
pub rcache: RefCell<HashMap<creader_cache_key, &'tcx TyS<'tcx>, DefaultState<FnvHasher>>>,
pub short_names_cache: RefCell<HashMap<&'tcx TyS<'tcx>, String, DefaultState<FnvHasher>>>,
pub tc_cache: RefCell<HashMap<&'tcx TyS<'tcx>, TypeContents, DefaultState<FnvHasher>>>,
pub ast_ty_to_ty_cache: RefCell<HashMap<u32, &'tcx TyS<'tcx>, DefaultState<FnvHasher>>>,
pub enum_var_cache: RefCell<HashMap<DefId, Rc<Vec<Rc<VariantInfo<'tcx>>>>, DefaultState<FnvHasher>>>,
pub ty_param_defs: RefCell<HashMap<u32, TypeParameterDef<'tcx>, DefaultState<FnvHasher>>>,
pub adjustments: RefCell<HashMap<u32, AutoAdjustment<'tcx>, DefaultState<FnvHasher>>>,
pub normalized_cache: RefCell<HashMap<&'tcx TyS<'tcx>, &'tcx TyS<'tcx>, DefaultState<FnvHasher>>>,
pub lang_items: LanguageItems,
pub provided_method_sources: RefCell<HashMap<DefId, DefId, DefaultState<FnvHasher>>>,
pub struct_fields: RefCell<HashMap<DefId, Rc<Vec<field_ty>>, DefaultState<FnvHasher>>>,
pub item_variance_map: RefCell<HashMap<DefId, Rc<ItemVariances>, DefaultState<FnvHasher>>>,
pub variance_computed: Cell<bool>,
pub destructor_for_type: RefCell<HashMap<DefId, DefId, DefaultState<FnvHasher>>>,
pub destructors: RefCell<HashSet<DefId, DefaultState<FnvHasher>>>,
pub inherent_impls: RefCell<HashMap<DefId, Rc<Vec<DefId>>, DefaultState<FnvHasher>>>,
pub impl_items: RefCell<HashMap<DefId, Vec<ImplOrTraitItemId>, DefaultState<FnvHasher>>>,
pub used_unsafe: RefCell<HashSet<u32, DefaultState<FnvHasher>>>,
pub used_mut_nodes: RefCell<HashSet<u32, DefaultState<FnvHasher>>>,
pub populated_external_types: RefCell<HashSet<DefId, DefaultState<FnvHasher>>>,
pub populated_external_primitive_impls: RefCell<HashSet<DefId, DefaultState<FnvHasher>>>,
pub upvar_capture_map: RefCell<HashMap<UpvarId, UpvarCapture, DefaultState<FnvHasher>>>,
pub extern_const_statics: RefCell<HashMap<DefId, u32, DefaultState<FnvHasher>>>,
pub extern_const_variants: RefCell<HashMap<DefId, u32, DefaultState<FnvHasher>>>,
pub method_map: RefCell<HashMap<MethodCall, MethodCallee<'tcx>, DefaultState<FnvHasher>>>,
pub dependency_formats: RefCell<HashMap<CrateType, Vec<Option<LinkagePreference>>, DefaultState<FnvHasher>>>,
pub closure_kinds: RefCell<HashMap<DefId, ClosureKind, DefaultState<FnvHasher>>>,
pub closure_tys: RefCell<HashMap<DefId, ClosureTy<'tcx>, DefaultState<FnvHasher>>>,
pub node_lint_levels: RefCell<HashMap<(u32, LintId), (Level, LintSource), DefaultState<FnvHasher>>>,
pub transmute_restrictions: RefCell<Vec<TransmuteRestriction<'tcx>>>,
pub stability: RefCell<Index>,
pub associated_types: RefCell<HashMap<DefId, bool, DefaultState<FnvHasher>>>,
pub selection_cache: SelectionCache<'tcx>,
pub repr_hint_cache: RefCell<HashMap<DefId, Rc<Vec<ReprAttr>>, DefaultState<FnvHasher>>>,
pub type_impls_copy_cache: RefCell<HashMap<&'tcx TyS<'tcx>, bool, RandomState>>,
pub type_impls_sized_cache: RefCell<HashMap<&'tcx TyS<'tcx>, bool, RandomState>>,
pub const_qualif_map: RefCell<HashMap<u32, ConstQualif, DefaultState<FnvHasher>>>,
pub custom_coerce_unsized_kinds: RefCell<HashMap<DefId, CustomCoerceUnsized, DefaultState<FnvHasher>>>,
// 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 | Unstable Common types, pre-interned for your convenience. |
sess | Unstable |
def_map | Unstable |
named_region_map | Unstable |
region_maps | Unstable |
item_substs | Unstable 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 | Unstable Maps from a trait item to the trait item "descriptor" |
trait_item_def_ids | Unstable Maps from a trait def-id to a list of the def-ids of its trait items |
trait_items_cache | Unstable A cache for the trait_items() routine |
impl_trait_cache | Unstable |
impl_trait_refs | Unstable |
trait_defs | Unstable |
predicates | Unstable Maps from the def-id of an item (trait/struct/enum/fn) to its associated predicates. |
super_predicates | Unstable Maps from the def-id of a trait to the list of super-predicates. This is a subset of the full list of predicates. We store these in a separate map because we must evaluate them even during type conversion, often before the full predicates are available (note that supertraits have additional acyclicity requirements). |
object_cast_map | Unstable Maps from node-id of a trait object cast (like |
map | Unstable |
freevars | Unstable |
tcache | Unstable |
rcache | Unstable |
short_names_cache | Unstable |
tc_cache | Unstable |
ast_ty_to_ty_cache | Unstable |
enum_var_cache | Unstable |
ty_param_defs | Unstable |
adjustments | Unstable |
normalized_cache | Unstable |
lang_items | Unstable |
provided_method_sources | Unstable A mapping of fake provided method def_ids to the default implementation |
struct_fields | Unstable |
item_variance_map | Unstable Maps from def-id of a type or region parameter to its (inferred) variance. |
variance_computed | Unstable True if the variance has been computed yet; false otherwise. |
destructor_for_type | Unstable 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 | Unstable A method will be in this list if and only if it is a destructor. |
inherent_impls | Unstable 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 | Unstable 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 | Unstable Set of used unsafe nodes (functions or blocks). Unsafe nodes not present in this set can be warned about. |
used_mut_nodes | Unstable 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 | Unstable The set of external nominal types whose implementations have been read. This is used for lazy resolution of methods. |
populated_external_primitive_impls | Unstable The set of external primitive types whose implementations have been read. FIXME(arielb1): why is this separate from populated_external_types? |
upvar_capture_map | Unstable Borrows |
extern_const_statics | Unstable These two caches are used by const_eval when decoding external statics and variants that are found. |
extern_const_variants | Unstable |
method_map | Unstable |
dependency_formats | Unstable |
closure_kinds | Unstable Records the type of each closure. The def ID is the ID of the expression defining the closure. |
closure_tys | Unstable Records the type of each closure. The def ID is the ID of the expression defining the closure. |
node_lint_levels | Unstable |
transmute_restrictions | Unstable The types that must be asserted to be the same size for |
stability | Unstable Maps any item's def-id to its stability index. |
associated_types | Unstable Maps def IDs to true if and only if they're associated types. |
selection_cache | Unstable 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 | Unstable Caches the representation hints for struct definitions. |
type_impls_copy_cache | Unstable 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 | Unstable 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. |
const_qualif_map | Unstable Maps Expr NodeId's to their constant qualification. |
custom_coerce_unsized_kinds | Unstable Caches CoerceUnsized kinds for impls on custom types. |
Methods
impl<'tcx> ctxt<'tcx>
fn node_types(&self) -> Ref<HashMap<u32, &'tcx TyS<'tcx>, DefaultState<FnvHasher>>>
fn node_type_insert(&self, id: u32, ty: &'tcx TyS<'tcx>)
fn intern_trait_def(&self, def: TraitDef<'tcx>) -> &'tcx TraitDef<'tcx>
fn store_free_region_map(&self, id: u32, map: FreeRegionMap)
fn free_region_map(&self, id: u32) -> FreeRegionMap
impl<'tcx> ctxt<'tcx>
fn print_debug_stats(&self)
impl<'tcx> ctxt<'tcx>
fn mk_substs(&self, substs: Substs<'tcx>) -> &'tcx Substs<'tcx>
fn safe_to_unsafe_fn_ty(&self, bare_fn: &BareFnTy<'tcx>) -> &'tcx TyS<'tcx>
Create an unsafe fn ty based on a safe fn ty.