Skip to content

Commit 6a0f1af

Browse files
committed
Remove HirId to NodeId conversion APIs
1 parent a98f35f commit 6a0f1af

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

src/librustc_hir/definitions.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,6 @@ impl Definitions {
337337
self.local_def_id_to_hir_id(def_id)
338338
}
339339

340-
#[inline]
341-
pub fn hir_id_to_node_id(&self, hir_id: hir::HirId) -> ast::NodeId {
342-
self.hir_id_to_node_id[&hir_id]
343-
}
344-
345340
#[inline]
346341
pub fn local_def_id_to_hir_id(&self, id: LocalDefId) -> hir::HirId {
347342
let node_id = self.def_id_to_node_id[id];
@@ -356,7 +351,7 @@ impl Definitions {
356351

357352
#[inline]
358353
pub fn opt_hir_id_to_local_def_id(&self, hir_id: hir::HirId) -> Option<LocalDefId> {
359-
let node_id = self.hir_id_to_node_id(hir_id);
354+
let node_id = self.hir_id_to_node_id[&hir_id];
360355
self.opt_local_def_id(node_id)
361356
}
362357

src/librustc_middle/hir/map/collector.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
242242
// Make sure that the DepNode of some node coincides with the HirId
243243
// owner of that node.
244244
if cfg!(debug_assertions) {
245-
let node_id = self.definitions.hir_id_to_node_id(hir_id);
246-
247245
if hir_id.owner != self.current_dep_node_owner {
248-
let node_str = match self.definitions.opt_local_def_id(node_id) {
246+
let node_str = match self.definitions.opt_hir_id_to_local_def_id(hir_id) {
249247
Some(def_id) => self.definitions.def_path(def_id).to_string_no_crate(),
250248
None => format!("{:?}", node),
251249
};
@@ -335,9 +333,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
335333
debug!("visit_item: {:?}", i);
336334
debug_assert_eq!(
337335
i.hir_id.owner,
338-
self.definitions
339-
.opt_local_def_id(self.definitions.hir_id_to_node_id(i.hir_id))
340-
.unwrap()
336+
self.definitions.opt_hir_id_to_local_def_id(i.hir_id).unwrap()
341337
);
342338
self.with_dep_node_owner(i.hir_id.owner, i, |this, hash| {
343339
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> {
369365
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
370366
debug_assert_eq!(
371367
ti.hir_id.owner,
372-
self.definitions
373-
.opt_local_def_id(self.definitions.hir_id_to_node_id(ti.hir_id))
374-
.unwrap()
368+
self.definitions.opt_hir_id_to_local_def_id(ti.hir_id).unwrap()
375369
);
376370
self.with_dep_node_owner(ti.hir_id.owner, ti, |this, hash| {
377371
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> {
385379
fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) {
386380
debug_assert_eq!(
387381
ii.hir_id.owner,
388-
self.definitions
389-
.opt_local_def_id(self.definitions.hir_id_to_node_id(ii.hir_id))
390-
.unwrap()
382+
self.definitions.opt_hir_id_to_local_def_id(ii.hir_id).unwrap()
391383
);
392384
self.with_dep_node_owner(ii.hir_id.owner, ii, |this, hash| {
393385
this.insert_with_hash(ii.span, ii.hir_id, Node::ImplItem(ii), hash);

0 commit comments

Comments
 (0)