about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2019-02-03 22:27:52 +0100
committerljedrz <ljedrz@gmail.com>2019-02-03 22:27:52 +0100
commit272f4dfff6d0a6ae172e3efbef7d563ea088f6fd (patch)
tree635779e6087df5e690472336b6ab80ac1ef31334 /src
parente8aeb83a4a1f242c4ff1394b645cc180fcdd5b23 (diff)
downloadrust-272f4dfff6d0a6ae172e3efbef7d563ea088f6fd.tar.gz
rust-272f4dfff6d0a6ae172e3efbef7d563ea088f6fd.zip
hir: remove Definitions::hir_to_def_index
Diffstat (limited to 'src')
-rw-r--r--src/librustc/hir/map/definitions.rs25
-rw-r--r--src/librustc/hir/map/mod.rs7
2 files changed, 5 insertions, 27 deletions
diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs
index 687daca3d3f..4c622adefbd 100644
--- a/src/librustc/hir/map/definitions.rs
+++ b/src/librustc/hir/map/definitions.rs
@@ -20,7 +20,7 @@ use syntax::ast;
 use syntax::ext::hygiene::Mark;
 use syntax::symbol::{Symbol, InternedString};
 use syntax_pos::{Span, DUMMY_SP};
-use util::nodemap::{HirIdMap, NodeMap};
+use util::nodemap::NodeMap;
 
 /// The DefPathTable maps DefIndexes to DefKeys and vice versa.
 /// Internally the DefPathTable holds a tree of DefKeys, where each DefKey
@@ -147,7 +147,6 @@ impl Decodable for DefPathTable {
 pub struct Definitions {
     table: DefPathTable,
     node_to_def_index: NodeMap<DefIndex>,
-    hir_to_def_index: HirIdMap<DefIndex>,
     def_index_to_node: [Vec<ast::NodeId>; 2],
     pub(super) node_to_hir_id: IndexVec<ast::NodeId, hir::HirId>,
     /// If `Mark` is an ID of some macro expansion,
@@ -442,34 +441,16 @@ impl Definitions {
         self.node_to_def_index.get(&node).cloned()
     }
 
-    // FIXME(@ljedrz): replace the NodeId variant
-    #[inline]
-    pub fn opt_def_index_from_hir_id(&self, hir: hir::HirId) -> Option<DefIndex> {
-        self.hir_to_def_index.get(&hir).cloned()
-    }
-
     #[inline]
     pub fn opt_local_def_id(&self, node: ast::NodeId) -> Option<DefId> {
         self.opt_def_index(node).map(DefId::local)
     }
 
-    // FIXME(@ljedrz): replace the NodeId variant
-    #[inline]
-    pub fn opt_local_def_id_from_hir_id(&self, hir: hir::HirId) -> Option<DefId> {
-        self.opt_def_index_from_hir_id(hir).map(DefId::local)
-    }
-
     #[inline]
     pub fn local_def_id(&self, node: ast::NodeId) -> DefId {
         self.opt_local_def_id(node).unwrap()
     }
 
-    // FIXME(@ljedrz): replace the NodeId variant
-    #[inline]
-    pub fn local_def_id_from_hir_id(&self, hir: hir::HirId) -> DefId {
-        self.opt_local_def_id_from_hir_id(hir).unwrap()
-    }
-
     #[inline]
     pub fn as_local_node_id(&self, def_id: DefId) -> Option<ast::NodeId> {
         if def_id.krate == LOCAL_CRATE {
@@ -549,7 +530,6 @@ impl Definitions {
         assert!(self.def_index_to_node[address_space.index()].is_empty());
         self.def_index_to_node[address_space.index()].push(ast::CRATE_NODE_ID);
         self.node_to_def_index.insert(ast::CRATE_NODE_ID, root_index);
-        self.hir_to_def_index.insert(hir::CRATE_HIR_ID, root_index);
 
         // Allocate some other DefIndices that always must exist.
         GlobalMetaDataKind::allocate_def_indices(self);
@@ -610,9 +590,6 @@ impl Definitions {
         if node_id != ast::DUMMY_NODE_ID {
             debug!("create_def_with_parent: def_index_to_node[{:?} <-> {:?}", index, node_id);
             self.node_to_def_index.insert(node_id, index);
-            if let Some(hir_id) = self.node_to_hir_id.get(node_id) {
-                self.hir_to_def_index.insert(*hir_id, index);
-            }
         }
 
         if expansion != Mark::root() {
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index c8e19c3b492..977ab05b209 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -252,8 +252,8 @@ impl<'hir> Map<'hir> {
     // FIXME(@ljedrz): replace the NodeId variant
     #[inline]
     pub fn local_def_id_from_hir_id(&self, hir_id: HirId) -> DefId {
-        self.opt_local_def_id_from_hir_id(hir_id).unwrap_or_else(|| {
-            let node_id = self.hir_to_node_id(hir_id);
+        let node_id = self.hir_to_node_id(hir_id);
+        self.opt_local_def_id(node_id).unwrap_or_else(|| {
             bug!("local_def_id_from_hir_id: no entry for `{:?}`, which has a map of `{:?}`",
                  hir_id, self.find_entry(node_id))
         })
@@ -262,7 +262,8 @@ impl<'hir> Map<'hir> {
     // FIXME(@ljedrz): replace the NodeId variant
     #[inline]
     pub fn opt_local_def_id_from_hir_id(&self, hir_id: HirId) -> Option<DefId> {
-        self.definitions.opt_local_def_id_from_hir_id(hir_id)
+        let node_id = self.hir_to_node_id(hir_id);
+        self.definitions.opt_local_def_id(node_id)
     }
 
     #[inline]