diff options
| author | marmeladema <xademax@gmail.com> | 2020-06-12 18:43:58 +0100 |
|---|---|---|
| committer | marmeladema <xademax@gmail.com> | 2020-06-20 11:03:58 +0100 |
| commit | 6a0f1af19d504635ea36efdf4ea68b1df935fc1b (patch) | |
| tree | 47126ad24d8ef3352f449e83e1651f0bf320b60a /src | |
| parent | a98f35f503ad4df9c6083d01447700c57436a0bc (diff) | |
| download | rust-6a0f1af19d504635ea36efdf4ea68b1df935fc1b.tar.gz rust-6a0f1af19d504635ea36efdf4ea68b1df935fc1b.zip | |
Remove `HirId` to `NodeId` conversion APIs
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_hir/definitions.rs | 7 | ||||
| -rw-r--r-- | src/librustc_middle/hir/map/collector.rs | 16 |
2 files changed, 5 insertions, 18 deletions
diff --git a/src/librustc_hir/definitions.rs b/src/librustc_hir/definitions.rs index 679fd1668dd..9913f92d2d9 100644 --- a/src/librustc_hir/definitions.rs +++ b/src/librustc_hir/definitions.rs @@ -338,11 +338,6 @@ impl Definitions { } #[inline] - pub fn hir_id_to_node_id(&self, hir_id: hir::HirId) -> ast::NodeId { - self.hir_id_to_node_id[&hir_id] - } - - #[inline] pub fn local_def_id_to_hir_id(&self, id: LocalDefId) -> hir::HirId { let node_id = self.def_id_to_node_id[id]; self.node_id_to_hir_id[node_id].unwrap() @@ -356,7 +351,7 @@ impl Definitions { #[inline] pub fn opt_hir_id_to_local_def_id(&self, hir_id: hir::HirId) -> Option<LocalDefId> { - let node_id = self.hir_id_to_node_id(hir_id); + let node_id = self.hir_id_to_node_id[&hir_id]; self.opt_local_def_id(node_id) } diff --git a/src/librustc_middle/hir/map/collector.rs b/src/librustc_middle/hir/map/collector.rs index ae169976698..dce06a5f7ee 100644 --- a/src/librustc_middle/hir/map/collector.rs +++ b/src/librustc_middle/hir/map/collector.rs @@ -242,10 +242,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { // Make sure that the DepNode of some node coincides with the HirId // owner of that node. if cfg!(debug_assertions) { - let node_id = self.definitions.hir_id_to_node_id(hir_id); - if hir_id.owner != self.current_dep_node_owner { - let node_str = match self.definitions.opt_local_def_id(node_id) { + let node_str = match self.definitions.opt_hir_id_to_local_def_id(hir_id) { Some(def_id) => self.definitions.def_path(def_id).to_string_no_crate(), None => format!("{:?}", node), }; @@ -335,9 +333,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { debug!("visit_item: {:?}", i); debug_assert_eq!( i.hir_id.owner, - self.definitions - .opt_local_def_id(self.definitions.hir_id_to_node_id(i.hir_id)) - .unwrap() + self.definitions.opt_hir_id_to_local_def_id(i.hir_id).unwrap() ); self.with_dep_node_owner(i.hir_id.owner, i, |this, hash| { this.insert_with_hash(i.span, i.hir_id, Node::Item(i), hash); @@ -369,9 +365,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) { debug_assert_eq!( ti.hir_id.owner, - self.definitions - .opt_local_def_id(self.definitions.hir_id_to_node_id(ti.hir_id)) - .unwrap() + self.definitions.opt_hir_id_to_local_def_id(ti.hir_id).unwrap() ); self.with_dep_node_owner(ti.hir_id.owner, ti, |this, hash| { this.insert_with_hash(ti.span, ti.hir_id, Node::TraitItem(ti), hash); @@ -385,9 +379,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) { debug_assert_eq!( ii.hir_id.owner, - self.definitions - .opt_local_def_id(self.definitions.hir_id_to_node_id(ii.hir_id)) - .unwrap() + self.definitions.opt_hir_id_to_local_def_id(ii.hir_id).unwrap() ); self.with_dep_node_owner(ii.hir_id.owner, ii, |this, hash| { this.insert_with_hash(ii.span, ii.hir_id, Node::ImplItem(ii), hash); |
