Skip to content

Commit 879ac1d

Browse files
committed
Revert "Remove NodeId to HirId conversion APIs"
This reverts commit a98f35f.
1 parent a95a0b9 commit 879ac1d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/librustc_hir/definitions.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl Definitions {
328328
#[inline]
329329
pub fn local_def_id(&self, node: ast::NodeId) -> LocalDefId {
330330
self.opt_local_def_id(node).unwrap_or_else(|| {
331-
panic!("no entry for node id: `{:?}` / `{:?}`", node, self.node_id_to_hir_id.get(node))
331+
panic!("no entry for node id: `{:?}` / `{:?}`", node, self.opt_node_id_to_hir_id(node))
332332
})
333333
}
334334

@@ -342,6 +342,16 @@ impl Definitions {
342342
self.hir_id_to_node_id[&hir_id]
343343
}
344344

345+
#[inline]
346+
pub fn node_id_to_hir_id(&self, node_id: ast::NodeId) -> hir::HirId {
347+
self.node_id_to_hir_id[node_id].unwrap()
348+
}
349+
350+
#[inline]
351+
pub fn opt_node_id_to_hir_id(&self, node_id: ast::NodeId) -> Option<hir::HirId> {
352+
self.node_id_to_hir_id[node_id]
353+
}
354+
345355
#[inline]
346356
pub fn local_def_id_to_hir_id(&self, id: LocalDefId) -> hir::HirId {
347357
let node_id = self.def_id_to_node_id[id];

src/librustc_middle/hir/map/collector.rs

+1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
243243
// owner of that node.
244244
if cfg!(debug_assertions) {
245245
let node_id = self.definitions.hir_id_to_node_id(hir_id);
246+
assert_eq!(self.definitions.node_id_to_hir_id(node_id), hir_id);
246247

247248
if hir_id.owner != self.current_dep_node_owner {
248249
let node_str = match self.definitions.opt_local_def_id(node_id) {

0 commit comments

Comments
 (0)