]> git.lizzy.rs Git - rust.git/commitdiff
rustc: consolidate dep-tracked hashmaps in tcx.maps.
authorEduard-Mihai Burtescu <edy.burt@gmail.com>
Tue, 7 Feb 2017 09:47:35 +0000 (11:47 +0200)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Sat, 25 Feb 2017 15:07:59 +0000 (17:07 +0200)
29 files changed:
src/librustc/middle/dead.rs
src/librustc/mir/transform.rs
src/librustc/traits/fulfill.rs
src/librustc/ty/context.rs
src/librustc/ty/item_path.rs
src/librustc/ty/maps.rs
src/librustc/ty/mod.rs
src/librustc/util/ppaux.rs
src/librustc_const_eval/eval.rs
src/librustc_driver/pretty.rs
src/librustc_lint/bad_style.rs
src/librustc_metadata/decoder.rs
src/librustc_metadata/encoder.rs
src/librustc_mir/mir_map.rs
src/librustc_passes/mir_stats.rs
src/librustc_save_analysis/dump_visitor.rs
src/librustc_trans/disr.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/check_unused.rs
src/librustc_typeck/coherence/builtin.rs
src/librustc_typeck/coherence/mod.rs
src/librustc_typeck/coherence/overlap.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/variance/constraints.rs
src/librustc_typeck/variance/solve.rs
src/librustc_typeck/variance/terms.rs
src/librustdoc/clean/inline.rs

index ae349667f9dc67826d36c80692865dc46a187836..592e4cb92359ce2d222850b969df4935296909f6 100644 (file)
@@ -478,7 +478,7 @@ fn symbol_is_live(&mut self,
         // method of a private type is used, but the type itself is never
         // called directly.
         if let Some(impl_list) =
-                self.tcx.inherent_impls.borrow().get(&self.tcx.hir.local_def_id(id)) {
+                self.tcx.maps.inherent_impls.borrow().get(&self.tcx.hir.local_def_id(id)) {
             for &impl_did in impl_list.iter() {
                 for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {
                     if let Some(item_node_id) = self.tcx.hir.as_local_node_id(item_did) {
index 652fef76f288a486b6ab6df8ef82bd4c15c1f16a..4cbbb67c7e43d8a1cd1caa7648b2064a2c215407 100644 (file)
@@ -114,14 +114,14 @@ fn run_pass<'a>(&mut self,
                     tcx: TyCtxt<'a, 'tcx, 'tcx>,
                     hooks: &mut [Box<for<'s> MirPassHook<'s>>])
     {
-        let def_ids = tcx.mir_map.borrow().keys();
+        let def_ids = tcx.maps.mir.borrow().keys();
         for def_id in def_ids {
             if !def_id.is_local() {
                 continue;
             }
 
             let _task = tcx.dep_graph.in_task(DepNode::Mir(def_id));
-            let mir = &mut tcx.mir_map.borrow()[&def_id].borrow_mut();
+            let mir = &mut tcx.maps.mir.borrow()[&def_id].borrow_mut();
             tcx.dep_graph.write(DepNode::Mir(def_id));
 
             let id = tcx.hir.as_local_node_id(def_id).unwrap();
index 23c28037a3c2d7b629f211c195446299032a6e0d..e28a8392e58d7da6e2ae1e838a9fbbeb0e1be6f2 100644 (file)
@@ -155,7 +155,7 @@ pub fn try_select(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>)
                       -> Option<Vec<PredicateObligation<'tcx>>> {
         if let ty::TyAnon(def_id, substs) = self.predicate.skip_binder().self_ty().sty {
             let ty = if def_id.is_local() {
-                tcx.item_types.borrow().get(&def_id).cloned()
+                tcx.maps.types.borrow().get(&def_id).cloned()
             } else {
                 Some(tcx.item_type(def_id))
             };
index c7e7fac275981eb77386b9b605e360f625f82476..665d60281d1a9b54ada85e163b056894860506bd 100644 (file)
@@ -10,7 +10,7 @@
 
 //! type context book-keeping
 
-use dep_graph::{DepGraph, DepTrackingMap};
+use dep_graph::DepGraph;
 use session::Session;
 use lint;
 use middle;
@@ -412,44 +412,9 @@ pub struct GlobalCtxt<'tcx> {
     // borrowck. (They are not used during trans, and hence are not
     // serialized or needed for cross-crate fns.)
     free_region_maps: RefCell<NodeMap<FreeRegionMap>>,
-    // FIXME: jroesch make this a refcell
-
-    pub tables: RefCell<DepTrackingMap<maps::TypeckTables<'tcx>>>,
-
-    /// Maps from a trait item to the trait item "descriptor"
-    pub associated_items: RefCell<DepTrackingMap<maps::AssociatedItems<'tcx>>>,
-
-    /// Maps from an impl/trait def-id to a list of the def-ids of its items
-    pub associated_item_def_ids: RefCell<DepTrackingMap<maps::AssociatedItemDefIds<'tcx>>>,
-
-    pub impl_trait_refs: RefCell<DepTrackingMap<maps::ImplTraitRefs<'tcx>>>,
-    pub trait_defs: RefCell<DepTrackingMap<maps::TraitDefs<'tcx>>>,
-    pub adt_defs: RefCell<DepTrackingMap<maps::AdtDefs<'tcx>>>,
-    pub adt_sized_constraint: RefCell<DepTrackingMap<maps::AdtSizedConstraint<'tcx>>>,
-
-    /// Maps from the def-id of an item (trait/struct/enum/fn) to its
-    /// associated generics and predicates.
-    pub generics: RefCell<DepTrackingMap<maps::Generics<'tcx>>>,
-    pub predicates: RefCell<DepTrackingMap<maps::Predicates<'tcx>>>,
-
-    /// 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).
-    pub super_predicates: RefCell<DepTrackingMap<maps::Predicates<'tcx>>>,
 
     pub hir: hir_map::Map<'tcx>,
-
-    /// Maps from the def-id of a function/method or const/static
-    /// to its MIR. Mutation is done at an item granularity to
-    /// allow MIR optimization passes to function and still
-    /// access cross-crate MIR (e.g. inlining or const eval).
-    ///
-    /// Note that cross-crate MIR appears to be always borrowed
-    /// (in the `RefCell` sense) to prevent accidental mutation.
-    pub mir_map: RefCell<DepTrackingMap<maps::Mir<'tcx>>>,
+    pub maps: maps::Maps<'tcx>,
 
     // Records the free variables refrenced by every closure
     // expression. Do not track deps for this, just recompute it from
@@ -458,9 +423,6 @@ pub struct GlobalCtxt<'tcx> {
 
     pub maybe_unused_trait_imports: NodeSet,
 
-    // Records the type of every item.
-    pub item_types: RefCell<DepTrackingMap<maps::Types<'tcx>>>,
-
     // Internal cache for metadata decoding. No need to track deps on this.
     pub rcache: RefCell<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
 
@@ -474,18 +436,9 @@ pub struct GlobalCtxt<'tcx> {
 
     pub lang_items: middle::lang_items::LanguageItems,
 
-    /// Maps from def-id of a type or region parameter to its
-    /// (inferred) variance.
-    pub item_variance_map: RefCell<DepTrackingMap<maps::ItemVariances<'tcx>>>,
-
     /// True if the variance has been computed yet; false otherwise.
     pub variance_computed: Cell<bool>,
 
-    /// 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.
-    pub inherent_impls: RefCell<DepTrackingMap<maps::InherentImpls<'tcx>>>,
-
     /// Set of used unsafe nodes (functions or blocks). Unsafe nodes not
     /// present in this set can be warned about.
     pub used_unsafe: RefCell<NodeSet>,
@@ -495,10 +448,6 @@ pub struct GlobalCtxt<'tcx> {
     /// about.
     pub used_mut_nodes: RefCell<NodeSet>,
 
-    /// Set of trait imports actually used in the method resolution.
-    /// This is used for warning unused imports.
-    pub used_trait_imports: RefCell<DepTrackingMap<maps::UsedTraitImports<'tcx>>>,
-
     /// The set of external nominal types whose implementations have been read.
     /// This is used for lazy resolution of methods.
     pub populated_external_types: RefCell<DefIdSet>,
@@ -507,10 +456,6 @@ pub struct GlobalCtxt<'tcx> {
     /// FIXME(arielb1): why is this separate from populated_external_types?
     pub populated_external_primitive_impls: RefCell<DefIdSet>,
 
-    /// Results of evaluating monomorphic constants embedded in
-    /// other items, such as enum variant explicit discriminants.
-    pub monomorphic_const_eval: RefCell<DepTrackingMap<maps::MonomorphicConstEval<'tcx>>>,
-
     /// Maps any item's def-id to its stability index.
     pub stability: RefCell<stability::Index<'tcx>>,
 
@@ -529,23 +474,9 @@ pub struct GlobalCtxt<'tcx> {
     /// (i.e., no type or lifetime parameters).
     pub fulfilled_predicates: RefCell<traits::GlobalFulfilledPredicates<'tcx>>,
 
-    /// Caches the representation hints for struct definitions.
-    repr_hint_cache: RefCell<DepTrackingMap<maps::ReprHints<'tcx>>>,
-
     /// Maps Expr NodeId's to `true` iff `&expr` can have 'static lifetime.
     pub rvalue_promotable_to_static: RefCell<NodeMap<bool>>,
 
-    /// Caches CoerceUnsized kinds for impls on custom types.
-    pub custom_coerce_unsized_kinds: RefCell<DefIdMap<ty::adjustment::CustomCoerceUnsized>>,
-
-    /// Records the type of each closure. The def ID is the ID of the
-    /// expression defining the closure.
-    pub closure_tys: RefCell<DepTrackingMap<maps::ClosureTypes<'tcx>>>,
-
-    /// Records the type of each closure. The def ID is the ID of the
-    /// expression defining the closure.
-    pub closure_kinds: RefCell<DepTrackingMap<maps::ClosureKinds<'tcx>>>,
-
     /// Maps Fn items to a collection of fragment infos.
     ///
     /// The main goal is to identify data (each of which may be moved
@@ -754,46 +685,27 @@ pub fn create_and_enter<F, R>(s: &'tcx Session,
             named_region_map: named_region_map,
             region_maps: region_maps,
             free_region_maps: RefCell::new(FxHashMap()),
-            item_variance_map: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             variance_computed: Cell::new(false),
             sess: s,
             trait_map: resolutions.trait_map,
-            tables: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            impl_trait_refs: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            trait_defs: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            adt_defs: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            adt_sized_constraint: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            generics: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            predicates: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            super_predicates: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             fulfilled_predicates: RefCell::new(fulfilled_predicates),
             hir: hir,
-            mir_map: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
+            maps: maps::Maps::new(dep_graph),
             freevars: RefCell::new(resolutions.freevars),
             maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports,
-            item_types: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             rcache: RefCell::new(FxHashMap()),
             tc_cache: RefCell::new(FxHashMap()),
-            associated_items: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            associated_item_def_ids: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             normalized_cache: RefCell::new(FxHashMap()),
             inhabitedness_cache: RefCell::new(FxHashMap()),
             lang_items: lang_items,
-            inherent_impls: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             used_unsafe: RefCell::new(NodeSet()),
             used_mut_nodes: RefCell::new(NodeSet()),
-            used_trait_imports: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             populated_external_types: RefCell::new(DefIdSet()),
             populated_external_primitive_impls: RefCell::new(DefIdSet()),
-            monomorphic_const_eval: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             stability: RefCell::new(stability),
             selection_cache: traits::SelectionCache::new(),
             evaluation_cache: traits::EvaluationCache::new(),
-            repr_hint_cache: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             rvalue_promotable_to_static: RefCell::new(NodeMap()),
-            custom_coerce_unsized_kinds: RefCell::new(DefIdMap()),
-            closure_tys: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
-            closure_kinds: RefCell::new(DepTrackingMap::new(dep_graph.clone())),
             fragment_infos: RefCell::new(DefIdMap()),
             crate_name: Symbol::intern(crate_name),
             data_layout: data_layout,
@@ -1541,7 +1453,7 @@ pub fn mk_substs_trait(self,
 
     /// Obtain the representation annotation for a struct definition.
     pub fn lookup_repr_hints(self, did: DefId) -> Rc<Vec<attr::ReprAttr>> {
-        self.repr_hint_cache.memoize(did, || {
+        self.maps.repr_hints.memoize(did, || {
             Rc::new(self.get_attrs(did).iter().flat_map(|meta| {
                 attr::find_repr_attrs(self.sess.diagnostic(), meta).into_iter()
             }).collect())
index f45f00b4dec96bbf20590469c44687b98858a625..c31895b3e9df793e39a3162cef883084189929a5 100644 (file)
@@ -201,7 +201,7 @@ fn push_impl_path<T>(self,
         } else {
             // for local crates, check whether type info is
             // available; typeck might not have completed yet
-            self.impl_trait_refs.borrow().contains_key(&impl_def_id)
+            self.maps.impl_trait_refs.borrow().contains_key(&impl_def_id)
         };
 
         if !use_types {
index cedb0307495602696a47053091d62e3fe9a5ccce..3e37bd50f942c8932e0dceea92fa5e29d90e2f5d 100644 (file)
@@ -8,10 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use dep_graph::{DepNode, DepTrackingMapConfig};
+use dep_graph::{DepGraph, DepNode, DepTrackingMap, DepTrackingMapConfig};
 use hir::def_id::DefId;
 use middle::const_val::ConstVal;
-use mir;
 use ty::{self, Ty};
 use util::nodemap::DefIdSet;
 
 use std::rc::Rc;
 use syntax::attr;
 
-macro_rules! dep_map_ty {
-    ($ty_name:ident : $node_name:ident ($key:ty) -> $value:ty) => {
-        pub struct $ty_name<'tcx> {
+macro_rules! define_maps {
+    ($($(#[$attr:meta])* pub $field:ident: $node_name:ident($key:ty) -> $value:ty),*) => {
+        pub struct Maps<'tcx> {
+            $($(#[$attr])* pub $field: RefCell<DepTrackingMap<$field<'tcx>>>),*
+        }
+
+        impl<'tcx> Maps<'tcx> {
+            pub fn new(dep_graph: DepGraph) -> Self {
+                Maps {
+                    $($field: RefCell::new(DepTrackingMap::new(dep_graph.clone()))),*
+                }
+            }
+        }
+
+        $(#[allow(bad_style)]
+        pub struct $field<'tcx> {
             data: PhantomData<&'tcx ()>
         }
 
-        impl<'tcx> DepTrackingMapConfig for $ty_name<'tcx> {
+        impl<'tcx> DepTrackingMapConfig for $field<'tcx> {
             type Key = $key;
             type Value = $value;
             fn to_dep_node(key: &$key) -> DepNode<DefId> { DepNode::$node_name(*key) }
-        }
+        })*
     }
 }
 
-dep_map_ty! { AssociatedItems: AssociatedItems(DefId) -> ty::AssociatedItem }
-dep_map_ty! { Types: ItemSignature(DefId) -> Ty<'tcx> }
-dep_map_ty! { Generics: ItemSignature(DefId) -> &'tcx ty::Generics }
-dep_map_ty! { Predicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx> }
-dep_map_ty! { SuperPredicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx> }
-dep_map_ty! { AssociatedItemDefIds: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>> }
-dep_map_ty! { ImplTraitRefs: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>> }
-dep_map_ty! { TraitDefs: ItemSignature(DefId) -> &'tcx ty::TraitDef }
-dep_map_ty! { AdtDefs: ItemSignature(DefId) -> &'tcx ty::AdtDef }
-dep_map_ty! { AdtSizedConstraint: SizedConstraint(DefId) -> Ty<'tcx> }
-dep_map_ty! { ItemVariances: ItemSignature(DefId) -> Rc<Vec<ty::Variance>> }
-dep_map_ty! { InherentImpls: InherentImpls(DefId) -> Vec<DefId> }
-dep_map_ty! { ReprHints: ReprHints(DefId) -> Rc<Vec<attr::ReprAttr>> }
-dep_map_ty! { Mir: Mir(DefId) -> &'tcx RefCell<mir::Mir<'tcx>> }
-dep_map_ty! { ClosureKinds: ItemSignature(DefId) -> ty::ClosureKind }
-dep_map_ty! { ClosureTypes: ItemSignature(DefId) -> ty::ClosureTy<'tcx> }
-dep_map_ty! { TypeckTables: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx> }
-dep_map_ty! { UsedTraitImports: UsedTraitImports(DefId) -> DefIdSet }
-dep_map_ty! { MonomorphicConstEval: MonomorphicConstEval(DefId) -> Result<ConstVal, ()> }
+define_maps! {
+    /// Maps from a trait item to the trait item "descriptor"
+    pub associated_items: AssociatedItems(DefId) -> ty::AssociatedItem,
+
+    /// Records the type of every item.
+    pub types: ItemSignature(DefId) -> Ty<'tcx>,
+
+    /// Maps from the def-id of an item (trait/struct/enum/fn) to its
+    /// associated generics and predicates.
+    pub generics: ItemSignature(DefId) -> &'tcx ty::Generics,
+    pub predicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
+
+    /// 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).
+    pub super_predicates: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
+
+    /// Maps from an impl/trait def-id to a list of the def-ids of its items
+    pub associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
+
+    pub impl_trait_refs: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
+    pub trait_defs: ItemSignature(DefId) -> &'tcx ty::TraitDef,
+    pub adt_defs: ItemSignature(DefId) -> &'tcx ty::AdtDef,
+    pub adt_sized_constraint: SizedConstraint(DefId) -> Ty<'tcx>,
+
+    /// Maps from def-id of a type or region parameter to its
+    /// (inferred) variance.
+    pub variances: ItemSignature(DefId) -> Rc<Vec<ty::Variance>>,
+
+    /// 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.
+    pub inherent_impls: InherentImpls(DefId) -> Vec<DefId>,
+
+    /// Caches the representation hints for struct definitions.
+    pub repr_hints: ReprHints(DefId) -> Rc<Vec<attr::ReprAttr>>,
+
+    /// Maps from the def-id of a function/method or const/static
+    /// to its MIR. Mutation is done at an item granularity to
+    /// allow MIR optimization passes to function and still
+    /// access cross-crate MIR (e.g. inlining or const eval).
+    ///
+    /// Note that cross-crate MIR appears to be always borrowed
+    /// (in the `RefCell` sense) to prevent accidental mutation.
+    pub mir: Mir(DefId) -> &'tcx RefCell<::mir::Mir<'tcx>>,
+
+    /// Records the type of each closure. The def ID is the ID of the
+    /// expression defining the closure.
+    pub closure_kinds: ItemSignature(DefId) -> ty::ClosureKind,
+
+    /// Records the type of each closure. The def ID is the ID of the
+    /// expression defining the closure.
+    pub closure_types: ItemSignature(DefId) -> ty::ClosureTy<'tcx>,
+
+    /// Caches CoerceUnsized kinds for impls on custom types.
+    pub custom_coerce_unsized_kinds: ItemSignature(DefId)
+        -> ty::adjustment::CustomCoerceUnsized,
+
+    pub typeck_tables: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
+
+    /// Set of trait imports actually used in the method resolution.
+    /// This is used for warning unused imports.
+    pub used_trait_imports: UsedTraitImports(DefId) -> DefIdSet,
+
+    /// Results of evaluating monomorphic constants embedded in
+    /// other items, such as enum variant explicit discriminants.
+    pub monomorphic_const_eval: MonomorphicConstEval(DefId) -> Result<ConstVal, ()>
+}
index be4ec881482d1870957c50a241fdf996a24440de..7e0a35916d0bcf23e57ae3d806133d482a22139c 100644 (file)
@@ -1592,7 +1592,7 @@ pub fn discriminants(&'a self, tcx: TyCtxt<'a, 'gcx, 'tcx>)
         self.variants.iter().map(move |v| {
             let mut discr = prev_discr.map_or(initial, |d| d.wrap_incr());
             if let VariantDiscr::Explicit(expr_did) = v.discr {
-                match tcx.monomorphic_const_eval.borrow()[&expr_did] {
+                match tcx.maps.monomorphic_const_eval.borrow()[&expr_did] {
                     Ok(ConstVal::Integral(v)) => {
                         discr = v;
                     }
@@ -1646,7 +1646,7 @@ fn calculate_sized_constraint_inner(&self,
                                         stack: &mut Vec<DefId>)
                                         -> Ty<'tcx>
     {
-        if let Some(ty) = tcx.adt_sized_constraint.borrow().get(&self.did) {
+        if let Some(ty) = tcx.maps.adt_sized_constraint.borrow().get(&self.did) {
             return ty;
         }
 
@@ -1660,7 +1660,7 @@ fn calculate_sized_constraint_inner(&self,
             //
             // Consider the type as Sized in the meanwhile to avoid
             // further errors.
-            tcx.adt_sized_constraint.borrow_mut().insert(self.did, tcx.types.err);
+            tcx.maps.adt_sized_constraint.borrow_mut().insert(self.did, tcx.types.err);
             return tcx.types.err;
         }
 
@@ -1684,7 +1684,7 @@ fn calculate_sized_constraint_inner(&self,
             _ => tcx.intern_tup(&tys[..], false)
         };
 
-        let old = tcx.adt_sized_constraint.borrow().get(&self.did).cloned();
+        let old = tcx.maps.adt_sized_constraint.borrow().get(&self.did).cloned();
         match old {
             Some(old_ty) => {
                 debug!("calculate_sized_constraint: {:?} recurred", self);
@@ -1693,7 +1693,7 @@ fn calculate_sized_constraint_inner(&self,
             }
             None => {
                 debug!("calculate_sized_constraint: {:?} => {:?}", self, ty);
-                tcx.adt_sized_constraint.borrow_mut().insert(self.did, ty);
+                tcx.maps.adt_sized_constraint.borrow_mut().insert(self.did, ty);
                 ty
             }
         }
@@ -1969,7 +1969,7 @@ pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> {
     }
 
     pub fn item_tables(self, def_id: DefId) -> &'gcx TypeckTables<'gcx> {
-        self.tables.memoize(def_id, || {
+        self.maps.typeck_tables.memoize(def_id, || {
             if def_id.is_local() {
                 // Closures' tables come from their outermost function,
                 // as they are part of the same "inference environment".
@@ -1983,7 +1983,7 @@ pub fn item_tables(self, def_id: DefId) -> &'gcx TypeckTables<'gcx> {
 
             // Cross-crate side-tables only exist alongside serialized HIR.
             self.sess.cstore.maybe_get_item_body(self.global_tcx(), def_id).map(|_| {
-                self.tables.borrow()[&def_id]
+                self.maps.typeck_tables.borrow()[&def_id]
             }).unwrap_or_else(|| {
                 bug!("tcx.item_tables({:?}): missing from metadata", def_id)
             })
@@ -2095,7 +2095,7 @@ pub fn trait_relevant_for_never(self, did: DefId) -> bool {
     }
 
     pub fn custom_coerce_unsized_kind(self, did: DefId) -> adjustment::CustomCoerceUnsized {
-        self.custom_coerce_unsized_kinds.memoize(did, || {
+        self.maps.custom_coerce_unsized_kinds.memoize(did, || {
             let (kind, src) = if did.krate != LOCAL_CRATE {
                 (self.sess.cstore.custom_coerce_unsized_kind(did), "external")
             } else {
@@ -2114,7 +2114,7 @@ pub fn custom_coerce_unsized_kind(self, did: DefId) -> adjustment::CustomCoerceU
     }
 
     pub fn associated_item(self, def_id: DefId) -> AssociatedItem {
-        self.associated_items.memoize(def_id, || {
+        self.maps.associated_items.memoize(def_id, || {
             if !def_id.is_local() {
                 return self.sess.cstore.associated_item(def_id)
                            .expect("missing AssociatedItem in metadata");
@@ -2141,7 +2141,8 @@ pub fn associated_item(self, def_id: DefId) -> AssociatedItem {
                             self.associated_item_from_impl_item_ref(parent_def_id,
                                                                     impl_trait_ref.is_some(),
                                                                     impl_item_ref);
-                        self.associated_items.borrow_mut().insert(assoc_item.def_id, assoc_item);
+                        self.maps.associated_items.borrow_mut()
+                            .insert(assoc_item.def_id, assoc_item);
                     }
                 }
 
@@ -2149,7 +2150,8 @@ pub fn associated_item(self, def_id: DefId) -> AssociatedItem {
                     for trait_item_ref in trait_item_refs {
                         let assoc_item =
                             self.associated_item_from_trait_item_ref(parent_def_id, trait_item_ref);
-                        self.associated_items.borrow_mut().insert(assoc_item.def_id, assoc_item);
+                        self.maps.associated_items.borrow_mut()
+                            .insert(assoc_item.def_id, assoc_item);
                     }
                 }
 
@@ -2160,7 +2162,7 @@ pub fn associated_item(self, def_id: DefId) -> AssociatedItem {
 
             // memoize wants us to return something, so return
             // the one we generated for this def-id
-            *self.associated_items.borrow().get(&def_id).unwrap()
+            *self.maps.associated_items.borrow().get(&def_id).unwrap()
         })
     }
 
@@ -2218,7 +2220,7 @@ fn associated_item_from_impl_item_ref(self,
     }
 
     pub fn associated_item_def_ids(self, def_id: DefId) -> Rc<Vec<DefId>> {
-        self.associated_item_def_ids.memoize(def_id, || {
+        self.maps.associated_item_def_ids.memoize(def_id, || {
             if !def_id.is_local() {
                 return Rc::new(self.sess.cstore.associated_item_def_ids(def_id));
             }
@@ -2255,7 +2257,7 @@ pub fn associated_items(self, def_id: DefId)
     /// an inherent impl.
     pub fn impl_trait_ref(self, id: DefId) -> Option<TraitRef<'gcx>> {
         lookup_locally_or_in_crate_store(
-            "impl_trait_refs", id, &self.impl_trait_refs,
+            "impl_trait_refs", id, &self.maps.impl_trait_refs,
             || self.sess.cstore.impl_trait_ref(self.global_tcx(), id))
     }
 
@@ -2336,14 +2338,14 @@ pub fn item_name(self, id: DefId) -> ast::Name {
     // the type cache. Returns the type parameters and type.
     pub fn item_type(self, did: DefId) -> Ty<'gcx> {
         lookup_locally_or_in_crate_store(
-            "item_types", did, &self.item_types,
+            "item_types", did, &self.maps.types,
             || self.sess.cstore.item_type(self.global_tcx(), did))
     }
 
     /// Given the did of a trait, returns its canonical trait ref.
     pub fn lookup_trait_def(self, did: DefId) -> &'gcx TraitDef {
         lookup_locally_or_in_crate_store(
-            "trait_defs", did, &self.trait_defs,
+            "trait_defs", did, &self.maps.trait_defs,
             || self.alloc_trait_def(self.sess.cstore.trait_def(self.global_tcx(), did))
         )
     }
@@ -2351,34 +2353,34 @@ pub fn lookup_trait_def(self, did: DefId) -> &'gcx TraitDef {
     /// Given the did of an ADT, return a reference to its definition.
     pub fn lookup_adt_def(self, did: DefId) -> &'gcx AdtDef {
         lookup_locally_or_in_crate_store(
-            "adt_defs", did, &self.adt_defs,
+            "adt_defs", did, &self.maps.adt_defs,
             || self.sess.cstore.adt_def(self.global_tcx(), did))
     }
 
     /// Given the did of an item, returns its generics.
     pub fn item_generics(self, did: DefId) -> &'gcx Generics {
         lookup_locally_or_in_crate_store(
-            "generics", did, &self.generics,
+            "generics", did, &self.maps.generics,
             || self.alloc_generics(self.sess.cstore.item_generics(did)))
     }
 
     /// Given the did of an item, returns its full set of predicates.
     pub fn item_predicates(self, did: DefId) -> GenericPredicates<'gcx> {
         lookup_locally_or_in_crate_store(
-            "predicates", did, &self.predicates,
+            "predicates", did, &self.maps.predicates,
             || self.sess.cstore.item_predicates(self.global_tcx(), did))
     }
 
     /// Given the did of a trait, returns its superpredicates.
     pub fn item_super_predicates(self, did: DefId) -> GenericPredicates<'gcx> {
         lookup_locally_or_in_crate_store(
-            "super_predicates", did, &self.super_predicates,
+            "super_predicates", did, &self.maps.super_predicates,
             || self.sess.cstore.item_super_predicates(self.global_tcx(), did))
     }
 
     /// Given the did of an item, returns its MIR, borrowed immutably.
     pub fn item_mir(self, did: DefId) -> Ref<'gcx, Mir<'gcx>> {
-        lookup_locally_or_in_crate_store("mir_map", did, &self.mir_map, || {
+        lookup_locally_or_in_crate_store("mir_map", did, &self.maps.mir, || {
             let mir = self.sess.cstore.get_item_mir(self.global_tcx(), did);
             let mir = self.alloc_mir(mir);
 
@@ -2450,7 +2452,7 @@ pub fn lookup_simd(self, did: DefId) -> bool {
 
     pub fn item_variances(self, item_id: DefId) -> Rc<Vec<ty::Variance>> {
         lookup_locally_or_in_crate_store(
-            "item_variance_map", item_id, &self.item_variance_map,
+            "item_variance_map", item_id, &self.maps.variances,
             || Rc::new(self.sess.cstore.item_variances(item_id)))
     }
 
@@ -2488,7 +2490,7 @@ pub fn populate_inherent_implementations_for_type_if_necessary(self,
 
         let inherent_impls = self.sess.cstore.inherent_implementations_for_type(type_id);
 
-        self.inherent_impls.borrow_mut().insert(type_id, inherent_impls);
+        self.maps.inherent_impls.borrow_mut().insert(type_id, inherent_impls);
         self.populated_external_types.borrow_mut().insert(type_id);
     }
 
@@ -2529,12 +2531,12 @@ pub fn closure_kind(self, def_id: DefId) -> ty::ClosureKind {
         // If this is a local def-id, it should be inserted into the
         // tables by typeck; else, it will be retreived from
         // the external crate metadata.
-        if let Some(&kind) = self.closure_kinds.borrow().get(&def_id) {
+        if let Some(&kind) = self.maps.closure_kinds.borrow().get(&def_id) {
             return kind;
         }
 
         let kind = self.sess.cstore.closure_kind(def_id);
-        self.closure_kinds.borrow_mut().insert(def_id, kind);
+        self.maps.closure_kinds.borrow_mut().insert(def_id, kind);
         kind
     }
 
@@ -2546,12 +2548,12 @@ pub fn closure_type(self,
         // If this is a local def-id, it should be inserted into the
         // tables by typeck; else, it will be retreived from
         // the external crate metadata.
-        if let Some(ty) = self.closure_tys.borrow().get(&def_id) {
+        if let Some(ty) = self.maps.closure_types.borrow().get(&def_id) {
             return ty.subst(self, substs.substs);
         }
 
         let ty = self.sess.cstore.closure_ty(self.global_tcx(), def_id);
-        self.closure_tys.borrow_mut().insert(def_id, ty.clone());
+        self.maps.closure_types.borrow_mut().insert(def_id, ty.clone());
         ty.subst(self, substs.substs)
     }
 
@@ -2572,7 +2574,7 @@ pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
                 }
             });
         }
-        match self.associated_items.borrow().get(&def_id).cloned() {
+        match self.maps.associated_items.borrow().get(&def_id).cloned() {
             Some(trait_item) => {
                 match trait_item.container {
                     TraitContainer(_) => None,
@@ -2590,7 +2592,7 @@ pub fn trait_of_item(self, def_id: DefId) -> Option<DefId> {
         if def_id.krate != LOCAL_CRATE {
             return self.sess.cstore.trait_of_item(def_id);
         }
-        match self.associated_items.borrow().get(&def_id) {
+        match self.maps.associated_items.borrow().get(&def_id) {
             Some(associated_item) => {
                 match associated_item.container {
                     TraitContainer(def_id) => Some(def_id),
index 2a5cd7b37cae4ffc0e76e3687c7325251fa4b31a..fa53760eca4666dd2ffe0b4e1f557b98f7a798f8 100644 (file)
@@ -770,7 +770,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             TyAdt(def, substs) => {
                 ty::tls::with(|tcx| {
                     if def.did.is_local() &&
-                          !tcx.item_types.borrow().contains_key(&def.did) {
+                          !tcx.maps.types.borrow().contains_key(&def.did) {
                         write!(f, "{}<..>", tcx.item_path_str(def.did))
                     } else {
                         parameterized(f, substs, def.did, &[])
index af4f63a05613eef94f20438b98343163cf7d0c35..13ece31f4ce13eb4a52938855dbf5cb1aa46cc73 100644 (file)
@@ -58,7 +58,7 @@ fn lookup_variant_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                         return variant.node.disr_expr.map(|e| {
                             let def_id = tcx.hir.body_owner_def_id(e);
                             (&tcx.hir.body(e).value,
-                             tcx.tables.borrow().get(&def_id).cloned())
+                             tcx.maps.typeck_tables.borrow().get(&def_id).cloned())
                         });
                     }
                 }
@@ -89,7 +89,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 node: hir::ImplItemKind::Const(ref ty, body), ..
             })) => {
                 Some((&tcx.hir.body(body).value,
-                      tcx.tables.borrow().get(&def_id).cloned(),
+                      tcx.maps.typeck_tables.borrow().get(&def_id).cloned(),
                       tcx.ast_ty_to_prim_ty(ty)))
             }
             Some(hir_map::NodeTraitItem(ti)) => match ti.node {
@@ -102,7 +102,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                         let trait_id = tcx.hir.local_def_id(trait_id);
                         let default_value = default.map(|body| {
                             (&tcx.hir.body(body).value,
-                             tcx.tables.borrow().get(&def_id).cloned(),
+                             tcx.maps.typeck_tables.borrow().get(&def_id).cloned(),
                              tcx.ast_ty_to_prim_ty(ty))
                         });
                         resolve_trait_associated_const(tcx, def_id, default_value, trait_id, substs)
@@ -156,7 +156,7 @@ fn lookup_const_fn_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
         FnLikeNode::from_node(tcx.hir.get(node_id)).and_then(|fn_like| {
             if fn_like.constness() == hir::Constness::Const {
                 Some((tcx.hir.body(fn_like.body()),
-                      tcx.tables.borrow().get(&def_id).cloned()))
+                      tcx.maps.typeck_tables.borrow().get(&def_id).cloned()))
             } else {
                 None
             }
@@ -231,7 +231,7 @@ pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, body: hir::BodyId) -> Self {
         let def_id = tcx.hir.body_owner_def_id(body);
         ConstContext {
             tcx: tcx,
-            tables: tcx.tables.borrow().get(&def_id).cloned(),
+            tables: tcx.maps.typeck_tables.borrow().get(&def_id).cloned(),
             fn_args: None
         }
     }
index 21fe13997b787d05e5c765b065aa910c5370e9b8..429e4ffef0c2a793efcb9c8289c5df1c2dd57bd6 100644 (file)
@@ -996,11 +996,13 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
                 } else {
                     match ppm {
                         PpmMir => {
-                            write_mir_pretty(tcx, tcx.mir_map.borrow().keys().into_iter(), &mut out)
+                            write_mir_pretty(tcx,
+                                             tcx.maps.mir.borrow().keys().into_iter(),
+                                             &mut out)
                         }
                         PpmMirCFG => {
                             write_mir_graphviz(tcx,
-                                               tcx.mir_map.borrow().keys().into_iter(),
+                                               tcx.maps.mir.borrow().keys().into_iter(),
                                                &mut out)
                         }
                         _ => unreachable!(),
index 0c86eb42e7acb745898b530695585c50abdfd224..5fcefe0d53997250b01c637c40ce4d8063fcd9ea 100644 (file)
@@ -29,7 +29,7 @@ pub enum MethodLateContext {
 
 pub fn method_context(cx: &LateContext, id: ast::NodeId, span: Span) -> MethodLateContext {
     let def_id = cx.tcx.hir.local_def_id(id);
-    match cx.tcx.associated_items.borrow().get(&def_id) {
+    match cx.tcx.maps.associated_items.borrow().get(&def_id) {
         None => span_bug!(span, "missing method descriptor?!"),
         Some(item) => {
             match item.container {
index 88b06e29e103ce3a0e7f00dc7cea166e7f1683b7..aa18fbe2ba8cdaaee35962dec7f7b89e5eb5cf66 100644 (file)
@@ -527,7 +527,7 @@ fn get_variant(&self,
 
         if let ty::VariantDiscr::Explicit(def_id) = data.discr {
             let result = data.evaluated_discr.map_or(Err(()), Ok);
-            tcx.monomorphic_const_eval.borrow_mut().insert(def_id, result);
+            tcx.maps.monomorphic_const_eval.borrow_mut().insert(def_id, result);
         }
 
         (ty::VariantDef {
@@ -584,7 +584,7 @@ pub fn get_adt_def(&self,
         let adt = tcx.alloc_adt_def(did, kind, variants, repr);
         if let Some(ctor_index) = ctor_index {
             // Make adt definition available through constructor id as well.
-            tcx.adt_defs.borrow_mut().insert(self.local_def_id(ctor_index), adt);
+            tcx.maps.adt_defs.borrow_mut().insert(self.local_def_id(ctor_index), adt);
         }
 
         adt
@@ -789,7 +789,7 @@ pub fn maybe_get_item_body(&self,
             let ast = ast.decode(self);
 
             let tables = ast.tables.decode((self, tcx));
-            tcx.tables.borrow_mut().insert(def_id, tcx.alloc_tables(tables));
+            tcx.maps.typeck_tables.borrow_mut().insert(def_id, tcx.alloc_tables(tables));
 
             let body = ast.body.decode((self, tcx));
             tcx.hir.intern_inlined_body(def_id, body)
index 725d54c227a3074a3864f94b2e3aece2207b0c39..e6110172fc41fe28ab6fd050cf363543ce13806f 100644 (file)
@@ -264,7 +264,7 @@ fn encode_enum_variant_info(&mut self,
             discr: variant.discr,
             evaluated_discr: match variant.discr {
                 ty::VariantDiscr::Explicit(def_id) => {
-                    tcx.monomorphic_const_eval.borrow()[&def_id].clone().ok()
+                    tcx.maps.monomorphic_const_eval.borrow()[&def_id].clone().ok()
                 }
                 ty::VariantDiscr::Relative(_) => None
             },
@@ -604,12 +604,12 @@ fn encode_fn_arg_names(&mut self, names: &[Spanned<ast::Name>])
     }
 
     fn encode_mir(&mut self, def_id: DefId) -> Option<Lazy<mir::Mir<'tcx>>> {
-        self.tcx.mir_map.borrow().get(&def_id).map(|mir| self.lazy(&*mir.borrow()))
+        self.tcx.maps.mir.borrow().get(&def_id).map(|mir| self.lazy(&*mir.borrow()))
     }
 
     // Encodes the inherent implementations of a structure, enumeration, or trait.
     fn encode_inherent_implementations(&mut self, def_id: DefId) -> LazySeq<DefIndex> {
-        match self.tcx.inherent_impls.borrow().get(&def_id) {
+        match self.tcx.maps.inherent_impls.borrow().get(&def_id) {
             None => LazySeq::empty(),
             Some(implementations) => {
                 self.lazy_seq(implementations.iter().map(|&def_id| {
@@ -711,7 +711,7 @@ fn encode_info_for_item(&mut self, (def_id, item): (DefId, &'tcx hir::Item)) ->
                 let data = ImplData {
                     polarity: polarity,
                     parent_impl: parent,
-                    coerce_unsized_kind: tcx.custom_coerce_unsized_kinds
+                    coerce_unsized_kind: tcx.maps.custom_coerce_unsized_kinds
                         .borrow()
                         .get(&def_id)
                         .cloned(),
@@ -1096,7 +1096,7 @@ fn encode_info_for_closure(&mut self, def_id: DefId) -> Entry<'tcx> {
 
         let data = ClosureData {
             kind: tcx.closure_kind(def_id),
-            ty: self.lazy(&tcx.closure_tys.borrow()[&def_id]),
+            ty: self.lazy(&tcx.maps.closure_types.borrow()[&def_id]),
         };
 
         Entry {
index b7f90682c7c74a5382a4824f2d48213125dada4c..913b0d5fb8ae883bc1d4d53aeb0a9f4eac5042c0 100644 (file)
@@ -139,7 +139,7 @@ fn visit_nested_body(&mut self, body_id: hir::BodyId) {
 
             let mir = tcx.alloc_mir(mir);
             let def_id = tcx.hir.local_def_id(src.item_id());
-            tcx.mir_map.borrow_mut().insert(def_id, mir);
+            tcx.maps.mir.borrow_mut().insert(def_id, mir);
         });
 
         let body = self.tcx.hir.body(body_id);
index 33b7089c38214543759808153fc3f52520bef57e..ad20c535decbbd63946aaa12abdd53da75dc8ad0 100644 (file)
@@ -44,7 +44,7 @@ pub fn print_mir_stats<'tcx, 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, title: &str) {
     // For debugging instrumentation like this, we don't need to worry
     // about maintaining the dep graph.
     let _ignore = tcx.dep_graph.in_ignore();
-    let mir_map = tcx.mir_map.borrow();
+    let mir_map = tcx.maps.mir.borrow();
     for def_id in mir_map.keys() {
         let mir = mir_map.get(&def_id).unwrap();
         collector.visit_mir(&mir.borrow());
index 6667a3199a8096ef5f4dd603d91465b8fa3d9c3d..3c275e0996dac0c3877c693f5bad6a7763cf0274 100644 (file)
@@ -112,7 +112,7 @@ fn nest_tables<F>(&mut self, item_id: NodeId, f: F)
         where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>)
     {
         let item_def_id = self.tcx.hir.local_def_id(item_id);
-        match self.tcx.tables.borrow().get(&item_def_id) {
+        match self.tcx.maps.typeck_tables.borrow().get(&item_def_id) {
             Some(tables) => {
                 let old_tables = self.save_ctxt.tables;
                 self.save_ctxt.tables = tables;
index 00c0e0d541586eeb92dc4f8f9d23ce26f967b342..a940faac8387735a7288f915564ea3b1dc0f88a0 100644 (file)
@@ -28,7 +28,7 @@ pub fn for_variant(tcx: TyCtxt,
                     explicit_index -= distance;
                 }
                 ty::VariantDiscr::Explicit(expr_did) => {
-                    match tcx.monomorphic_const_eval.borrow()[&expr_did] {
+                    match tcx.maps.monomorphic_const_eval.borrow()[&expr_did] {
                         Ok(ConstVal::Integral(v)) => {
                             explicit_value = Disr::from(v);
                             break;
index cd7474cf50b8c6cf4627f7f2a408680c9f545f3c..11ad47eef7159cc5b32c9f99808cf229bc933970 100644 (file)
@@ -1209,7 +1209,7 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
                                                 ast_ty.span);
                     let predicates = bounds.predicates(tcx, ty);
                     let predicates = tcx.lift_to_global(&predicates).unwrap();
-                    tcx.predicates.borrow_mut().insert(def_id, ty::GenericPredicates {
+                    tcx.maps.predicates.borrow_mut().insert(def_id, ty::GenericPredicates {
                         parent: None,
                         predicates: predicates
                     });
index fd29ff0be43b44910d5f7860cd1727bd169ec289..468a38cd2bace9f894c1da83438fadd401b2e839 100644 (file)
@@ -483,7 +483,7 @@ fn assemble_inherent_impl_candidates_for_type(&mut self, def_id: DefId) {
         // metadata if necessary.
         self.tcx.populate_inherent_implementations_for_type_if_necessary(def_id);
 
-        if let Some(impl_infos) = self.tcx.inherent_impls.borrow().get(&def_id) {
+        if let Some(impl_infos) = self.tcx.maps.inherent_impls.borrow().get(&def_id) {
             for &impl_def_id in impl_infos.iter() {
                 self.assemble_inherent_impl_probe(impl_def_id);
             }
index a25e5f3f283dd1520d966b474619e4440f246641..b3a4b83b6832c0e8dfb597c64bfadce8191dfdf9 100644 (file)
@@ -56,12 +56,12 @@ pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) {
         wbcx.visit_lints();
 
         let tables = self.tcx.alloc_tables(wbcx.tables);
-        self.tcx.tables.borrow_mut().insert(item_def_id, tables);
+        self.tcx.maps.typeck_tables.borrow_mut().insert(item_def_id, tables);
 
         let used_trait_imports = mem::replace(&mut *self.used_trait_imports.borrow_mut(),
                                               DefIdSet());
         debug!("used_trait_imports({:?}) = {:?}", item_def_id, used_trait_imports);
-        self.tcx.used_trait_imports.borrow_mut().insert(item_def_id, used_trait_imports);
+        self.tcx.maps.used_trait_imports.borrow_mut().insert(item_def_id, used_trait_imports);
     }
 }
 
@@ -290,12 +290,12 @@ fn visit_closures(&self) {
         for (&id, closure_ty) in self.fcx.tables.borrow().closure_tys.iter() {
             let closure_ty = self.resolve(closure_ty, ResolvingClosure(id));
             let def_id = self.tcx().hir.local_def_id(id);
-            self.tcx().closure_tys.borrow_mut().insert(def_id, closure_ty);
+            self.tcx().maps.closure_types.borrow_mut().insert(def_id, closure_ty);
         }
 
         for (&id, &closure_kind) in self.fcx.tables.borrow().closure_kinds.iter() {
             let def_id = self.tcx().hir.local_def_id(id);
-            self.tcx().closure_kinds.borrow_mut().insert(def_id, closure_kind);
+            self.tcx().maps.closure_kinds.borrow_mut().insert(def_id, closure_kind);
         }
     }
 
@@ -361,7 +361,7 @@ fn visit_anon_types(&self) {
                 }
             });
 
-            gcx.item_types.borrow_mut().insert(def_id, outside_ty);
+            gcx.maps.types.borrow_mut().insert(def_id, outside_ty);
         }
     }
 
index 6dff6d57e4facc1d576c06f0dcf89dcf6131f029..0f992f75fce34a94cd963f39706eeb43b61ad327 100644 (file)
@@ -70,7 +70,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
         let item_def_id = tcx.hir.local_def_id(item_id);
 
         // this will have been written by the main typeck pass
-        if let Some(imports) = tcx.used_trait_imports.borrow().get(&item_def_id) {
+        if let Some(imports) = tcx.maps.used_trait_imports.borrow().get(&item_def_id) {
             debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports);
             used_trait_imports.extend(imports);
         } else {
index 96875fce468d2e34473ddc0c2a7b25c37e3755de..e15386b87ad97ef3e589858c0d919c24daa1096b 100644 (file)
@@ -341,7 +341,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         infcx.resolve_regions_and_report_errors(&free_regions, impl_node_id);
 
         if let Some(kind) = kind {
-            tcx.custom_coerce_unsized_kinds.borrow_mut().insert(impl_did, kind);
+            tcx.maps.custom_coerce_unsized_kinds.borrow_mut().insert(impl_did, kind);
         }
     });
 }
index b6a863fd2ed0d533626972afbf1c6a219659a63d..1301f33d30b0819b21dbfbd93a99986f94b497e6 100644 (file)
@@ -39,7 +39,7 @@
 
 struct CoherenceCollect<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
-    inherent_impls: RefMut<'a, DepTrackingMap<maps::InherentImpls<'tcx>>>,
+    inherent_impls: RefMut<'a, DepTrackingMap<maps::inherent_impls<'tcx>>>,
 }
 
 impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CoherenceCollect<'a, 'tcx> {
@@ -58,7 +58,7 @@ fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem) {
 
 impl<'a, 'tcx> CoherenceCollect<'a, 'tcx> {
     fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
-        let inherent_impls = tcx.inherent_impls.borrow_mut();
+        let inherent_impls = tcx.maps.inherent_impls.borrow_mut();
         let mut this = &mut CoherenceCollect { tcx, inherent_impls };
 
         // Check implementations and traits. This populates the tables
index 56c17dc2f6efda144dbb9e2be510ab19648c57db..45493d40eb802e3375e9cda0b9bb253a81928b41 100644 (file)
@@ -79,7 +79,7 @@ enum Namespace {
     fn check_for_overlapping_inherent_impls(&self, ty_def_id: DefId) {
         let _task = self.tcx.dep_graph.in_task(DepNode::CoherenceOverlapInherentCheck(ty_def_id));
 
-        let inherent_impls = self.tcx.inherent_impls.borrow();
+        let inherent_impls = self.tcx.maps.inherent_impls.borrow();
         let impls = match inherent_impls.get(&ty_def_id) {
             Some(impls) => impls,
             None => return,
index 3f3fc40320eb63903856501d531eba20b938e0de..3851cd2bb442ad4bc1f0bcce9337409f8b373e43 100644 (file)
@@ -606,8 +606,8 @@ fn convert_field<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
 {
     generics_of_def_id(ccx, ty_f.did);
     let tt = ccx.icx(ty_f.did).to_ty(&field.ty);
-    ccx.tcx.item_types.borrow_mut().insert(ty_f.did, tt);
-    ccx.tcx.predicates.borrow_mut().insert(ty_f.did, ty::GenericPredicates {
+    ccx.tcx.maps.types.borrow_mut().insert(ty_f.did, tt);
+    ccx.tcx.maps.predicates.borrow_mut().insert(ty_f.did, ty::GenericPredicates {
         parent: Some(ccx.tcx.hir.get_parent_did(field.id)),
         predicates: vec![]
     });
@@ -619,7 +619,7 @@ fn convert_method(ccx: &CrateCtxt, id: ast::NodeId, sig: &hir::MethodSig) {
     let fty = AstConv::ty_of_fn(&ccx.icx(def_id), sig.unsafety, sig.abi, &sig.decl);
     let substs = mk_item_substs(ccx, def_id);
     let fty = ccx.tcx.mk_fn_def(def_id, substs, fty);
-    ccx.tcx.item_types.borrow_mut().insert(def_id, fty);
+    ccx.tcx.maps.types.borrow_mut().insert(def_id, fty);
 
     ty_generic_predicates(ccx, def_id, &sig.generics);
 }
@@ -634,8 +634,8 @@ fn convert_associated_const<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
         predicates: vec![]
     };
     let def_id = ccx.tcx.hir.local_def_id(id);
-    ccx.tcx.predicates.borrow_mut().insert(def_id, predicates);
-    ccx.tcx.item_types.borrow_mut().insert(def_id, ty);
+    ccx.tcx.maps.predicates.borrow_mut().insert(def_id, predicates);
+    ccx.tcx.maps.types.borrow_mut().insert(def_id, ty);
 }
 
 fn convert_associated_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
@@ -648,10 +648,10 @@ fn convert_associated_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
         predicates: vec![]
     };
     let def_id = ccx.tcx.hir.local_def_id(id);
-    ccx.tcx.predicates.borrow_mut().insert(def_id, predicates);
+    ccx.tcx.maps.predicates.borrow_mut().insert(def_id, predicates);
 
     if let Some(ty) = ty {
-        ccx.tcx.item_types.borrow_mut().insert(def_id, ty);
+        ccx.tcx.maps.types.borrow_mut().insert(def_id, ty);
     }
 }
 
@@ -725,8 +725,8 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
 
             tcx.record_trait_has_default_impl(trait_ref.def_id);
 
-            tcx.impl_trait_refs.borrow_mut().insert(ccx.tcx.hir.local_def_id(it.id),
-                                                    Some(trait_ref));
+            tcx.maps.impl_trait_refs.borrow_mut().insert(ccx.tcx.hir.local_def_id(it.id),
+                                                         Some(trait_ref));
         }
         hir::ItemImpl(.., ref opt_trait_ref, _, _) => {
             generics_of_def_id(ccx, def_id);
@@ -735,7 +735,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
             let trait_ref = opt_trait_ref.as_ref().map(|ast_trait_ref| {
                 AstConv::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty)
             });
-            tcx.impl_trait_refs.borrow_mut().insert(def_id, trait_ref);
+            tcx.maps.impl_trait_refs.borrow_mut().insert(def_id, trait_ref);
 
             predicates_of_item(ccx, it);
         },
@@ -864,8 +864,8 @@ fn convert_variant_ctor<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             }))
         }
     };
-    tcx.item_types.borrow_mut().insert(def_id, ctor_ty);
-    tcx.predicates.borrow_mut().insert(def_id, ty::GenericPredicates {
+    tcx.maps.types.borrow_mut().insert(def_id, ctor_ty);
+    tcx.maps.predicates.borrow_mut().insert(def_id, ty::GenericPredicates {
         parent: Some(ccx.tcx.hir.get_parent_did(ctor_id)),
         predicates: vec![]
     });
@@ -888,7 +888,7 @@ fn convert_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             let result = evaluate_disr_expr(ccx, repr_type, e);
 
             let expr_did = tcx.hir.local_def_id(e.node_id);
-            tcx.monomorphic_const_eval.borrow_mut()
+            tcx.maps.monomorphic_const_eval.borrow_mut()
                .insert(expr_did, result.map(ConstVal::Integral));
 
             result.ok()
@@ -966,10 +966,10 @@ fn convert_struct_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
         ReprOptions::new(&ccx.tcx, did));
     if let Some(ctor_id) = ctor_id {
         // Make adt definition available through constructor id as well.
-        ccx.tcx.adt_defs.borrow_mut().insert(ctor_id, adt);
+        ccx.tcx.maps.adt_defs.borrow_mut().insert(ctor_id, adt);
     }
 
-    ccx.tcx.adt_defs.borrow_mut().insert(did, adt);
+    ccx.tcx.maps.adt_defs.borrow_mut().insert(did, adt);
     adt
 }
 
@@ -983,7 +983,7 @@ fn convert_union_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                                                ty::VariantDiscr::Relative(0), def)];
 
     let adt = ccx.tcx.alloc_adt_def(did, AdtKind::Union, variants, ReprOptions::new(&ccx.tcx, did));
-    ccx.tcx.adt_defs.borrow_mut().insert(did, adt);
+    ccx.tcx.maps.adt_defs.borrow_mut().insert(did, adt);
     adt
 }
 
@@ -1061,7 +1061,7 @@ fn convert_enum_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
 
     let did = tcx.hir.local_def_id(it.id);
     let adt = tcx.alloc_adt_def(did, AdtKind::Enum, variants, ReprOptions::new(&ccx.tcx, did));
-    tcx.adt_defs.borrow_mut().insert(did, adt);
+    tcx.maps.adt_defs.borrow_mut().insert(did, adt);
     adt
 }
 
@@ -1091,7 +1091,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt,
         return Vec::new();
     };
 
-    let superpredicates = tcx.super_predicates.borrow().get(&trait_def_id).cloned();
+    let superpredicates = tcx.maps.super_predicates.borrow().get(&trait_def_id).cloned();
     let superpredicates = superpredicates.unwrap_or_else(|| {
         let item = match ccx.tcx.hir.get(trait_node_id) {
             hir_map::NodeItem(item) => item,
@@ -1130,7 +1130,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt,
                tcx.hir.local_def_id(item.id),
                superpredicates);
 
-        tcx.super_predicates.borrow_mut().insert(trait_def_id, superpredicates.clone());
+        tcx.maps.super_predicates.borrow_mut().insert(trait_def_id, superpredicates.clone());
 
         superpredicates
     });
@@ -1150,7 +1150,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &hir::Item) -> &'t
     let tcx = ccx.tcx;
     let def_id = tcx.hir.local_def_id(it.id);
 
-    tcx.trait_defs.memoize(def_id, || {
+    tcx.maps.trait_defs.memoize(def_id, || {
         let unsafety = match it.node {
             hir::ItemTrait(unsafety, ..) => unsafety,
             _ => span_bug!(it.span, "trait_def_of_item invoked on non-trait"),
@@ -1182,7 +1182,7 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
     } else {
         return tcx.item_generics(def_id);
     };
-    tcx.generics.memoize(def_id, || {
+    tcx.maps.generics.memoize(def_id, || {
         use rustc::hir::map::*;
         use rustc::hir::*;
 
@@ -1380,7 +1380,7 @@ fn type_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
     } else {
         return ccx.tcx.item_type(def_id);
     };
-    ccx.tcx.item_types.memoize(def_id, || {
+    ccx.tcx.maps.types.memoize(def_id, || {
         use rustc::hir::map::*;
         use rustc::hir::*;
 
@@ -1718,7 +1718,7 @@ fn ty_generic_predicates(ccx: &CrateCtxt, def_id: DefId, ast_generics: &hir::Gen
                                            &mut ctp::parameters_for_impl(self_ty, trait_ref));
     }
 
-    tcx.predicates.borrow_mut().insert(def_id, ty::GenericPredicates {
+    tcx.maps.predicates.borrow_mut().insert(def_id, ty::GenericPredicates {
         parent: generics.parent,
         predicates: predicates
     });
index b22db94079891c63a951c939bcdb173548a875b7..3d2b746b85548e0d36fcb52caf0ca1dc3954d4c7 100644 (file)
 //! The second pass over the AST determines the set of constraints.
 //! We walk the set of items and, for each member, generate new constraints.
 
-use dep_graph::DepTrackingMapConfig;
 use hir::def_id::DefId;
 use middle::resolve_lifetime as rl;
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, Ty, TyCtxt};
-use rustc::ty::maps::ItemVariances;
 use rustc::hir::map as hir_map;
 use syntax::ast;
 use rustc::hir;
@@ -28,6 +26,8 @@
 use super::terms::VarianceTerm::*;
 use super::xform::*;
 
+use dep_graph::DepNode::ItemSignature as VarianceDepNode;
+
 pub struct ConstraintContext<'a, 'tcx: 'a> {
     pub terms_cx: TermsContext<'a, 'tcx>,
 
@@ -65,8 +65,7 @@ pub fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>)
     };
 
     // See README.md for a discussion on dep-graph management.
-    tcx.visit_all_item_likes_in_krate(|def_id| ItemVariances::to_dep_node(&def_id),
-                                      &mut constraint_cx);
+    tcx.visit_all_item_likes_in_krate(VarianceDepNode, &mut constraint_cx);
 
     constraint_cx
 }
@@ -291,7 +290,7 @@ fn add_constraints_from_trait_ref(&mut self,
         // This edge is actually implied by the call to
         // `lookup_trait_def`, but I'm trying to be future-proof. See
         // README.md for a discussion on dep-graph management.
-        self.tcx().dep_graph.read(ItemVariances::to_dep_node(&trait_ref.def_id));
+        self.tcx().dep_graph.read(VarianceDepNode(trait_ref.def_id));
 
         self.add_constraints_from_substs(generics,
                                          trait_ref.def_id,
@@ -350,7 +349,7 @@ fn add_constraints_from_ty(&mut self,
                 // This edge is actually implied by the call to
                 // `lookup_trait_def`, but I'm trying to be future-proof. See
                 // README.md for a discussion on dep-graph management.
-                self.tcx().dep_graph.read(ItemVariances::to_dep_node(&def.did));
+                self.tcx().dep_graph.read(VarianceDepNode(def.did));
 
                 self.add_constraints_from_substs(generics,
                                                  def.did,
@@ -367,7 +366,7 @@ fn add_constraints_from_ty(&mut self,
                 // This edge is actually implied by the call to
                 // `lookup_trait_def`, but I'm trying to be future-proof. See
                 // README.md for a discussion on dep-graph management.
-                self.tcx().dep_graph.read(ItemVariances::to_dep_node(&trait_ref.def_id));
+                self.tcx().dep_graph.read(VarianceDepNode(trait_ref.def_id));
 
                 self.add_constraints_from_substs(generics,
                                                  trait_ref.def_id,
index 3ccec97d606ea3afa60a968ad831825c6a8edca6..6628c7c521fd103dec06ea7f5489b3f94d5dbecc 100644 (file)
@@ -137,7 +137,7 @@ fn write(&self) {
                           item_variances);
             }
 
-            tcx.item_variance_map
+            tcx.maps.variances
                .borrow_mut()
                .insert(item_def_id, Rc::new(item_variances));
         }
index 253d7a25b632f2fea0afd6a2e24b071b99b6cac8..36352f50e4406237115aa36abf42d55a53438c38 100644 (file)
@@ -20,9 +20,7 @@
 // a variable.
 
 use arena::TypedArena;
-use dep_graph::DepTrackingMapConfig;
 use rustc::ty::{self, TyCtxt};
-use rustc::ty::maps::ItemVariances;
 use std::fmt;
 use std::rc::Rc;
 use syntax::ast;
@@ -34,6 +32,8 @@
 
 pub type VarianceTermPtr<'a> = &'a VarianceTerm<'a>;
 
+use dep_graph::DepNode::ItemSignature as VarianceDepNode;
+
 #[derive(Copy, Clone, Debug)]
 pub struct InferredIndex(pub usize);
 
@@ -109,7 +109,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>
     };
 
     // See README.md for a discussion on dep-graph management.
-    tcx.visit_all_item_likes_in_krate(|def_id| ItemVariances::to_dep_node(&def_id), &mut terms_cx);
+    tcx.visit_all_item_likes_in_krate(|def_id| VarianceDepNode(def_id), &mut terms_cx);
 
     terms_cx
 }
@@ -178,8 +178,7 @@ fn add_inferreds_for_item(&mut self,
         // parameters".
         if self.num_inferred() == inferreds_on_entry {
             let item_def_id = self.tcx.hir.local_def_id(item_id);
-            self.tcx
-                .item_variance_map
+            self.tcx.maps.variances
                 .borrow_mut()
                 .insert(item_def_id, self.empty_variances.clone());
         }
index 93854193762fbcf2d2ef7a63e9f2c02250d846c2..02d934783d464a1d318066ba79aa7a82e4d4e3d5 100644 (file)
@@ -238,7 +238,7 @@ pub fn build_impls(cx: &DocContext, did: DefId) -> Vec<clean::Item> {
     tcx.populate_inherent_implementations_for_type_if_necessary(did);
     let mut impls = Vec::new();
 
-    if let Some(i) = tcx.inherent_impls.borrow().get(&did) {
+    if let Some(i) = tcx.maps.inherent_impls.borrow().get(&did) {
         for &did in i.iter() {
             build_impl(cx, did, &mut impls);
         }