Skip to content

Commit 272f4df

Browse files
committed
hir: remove Definitions::hir_to_def_index
1 parent e8aeb83 commit 272f4df

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

src/librustc/hir/map/definitions.rs

+1-24
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use syntax::ast;
2020
use syntax::ext::hygiene::Mark;
2121
use syntax::symbol::{Symbol, InternedString};
2222
use syntax_pos::{Span, DUMMY_SP};
23-
use util::nodemap::{HirIdMap, NodeMap};
23+
use util::nodemap::NodeMap;
2424

2525
/// The DefPathTable maps DefIndexes to DefKeys and vice versa.
2626
/// Internally the DefPathTable holds a tree of DefKeys, where each DefKey
@@ -147,7 +147,6 @@ impl Decodable for DefPathTable {
147147
pub struct Definitions {
148148
table: DefPathTable,
149149
node_to_def_index: NodeMap<DefIndex>,
150-
hir_to_def_index: HirIdMap<DefIndex>,
151150
def_index_to_node: [Vec<ast::NodeId>; 2],
152151
pub(super) node_to_hir_id: IndexVec<ast::NodeId, hir::HirId>,
153152
/// If `Mark` is an ID of some macro expansion,
@@ -442,34 +441,16 @@ impl Definitions {
442441
self.node_to_def_index.get(&node).cloned()
443442
}
444443

445-
// FIXME(@ljedrz): replace the NodeId variant
446-
#[inline]
447-
pub fn opt_def_index_from_hir_id(&self, hir: hir::HirId) -> Option<DefIndex> {
448-
self.hir_to_def_index.get(&hir).cloned()
449-
}
450-
451444
#[inline]
452445
pub fn opt_local_def_id(&self, node: ast::NodeId) -> Option<DefId> {
453446
self.opt_def_index(node).map(DefId::local)
454447
}
455448

456-
// FIXME(@ljedrz): replace the NodeId variant
457-
#[inline]
458-
pub fn opt_local_def_id_from_hir_id(&self, hir: hir::HirId) -> Option<DefId> {
459-
self.opt_def_index_from_hir_id(hir).map(DefId::local)
460-
}
461-
462449
#[inline]
463450
pub fn local_def_id(&self, node: ast::NodeId) -> DefId {
464451
self.opt_local_def_id(node).unwrap()
465452
}
466453

467-
// FIXME(@ljedrz): replace the NodeId variant
468-
#[inline]
469-
pub fn local_def_id_from_hir_id(&self, hir: hir::HirId) -> DefId {
470-
self.opt_local_def_id_from_hir_id(hir).unwrap()
471-
}
472-
473454
#[inline]
474455
pub fn as_local_node_id(&self, def_id: DefId) -> Option<ast::NodeId> {
475456
if def_id.krate == LOCAL_CRATE {
@@ -549,7 +530,6 @@ impl Definitions {
549530
assert!(self.def_index_to_node[address_space.index()].is_empty());
550531
self.def_index_to_node[address_space.index()].push(ast::CRATE_NODE_ID);
551532
self.node_to_def_index.insert(ast::CRATE_NODE_ID, root_index);
552-
self.hir_to_def_index.insert(hir::CRATE_HIR_ID, root_index);
553533

554534
// Allocate some other DefIndices that always must exist.
555535
GlobalMetaDataKind::allocate_def_indices(self);
@@ -610,9 +590,6 @@ impl Definitions {
610590
if node_id != ast::DUMMY_NODE_ID {
611591
debug!("create_def_with_parent: def_index_to_node[{:?} <-> {:?}", index, node_id);
612592
self.node_to_def_index.insert(node_id, index);
613-
if let Some(hir_id) = self.node_to_hir_id.get(node_id) {
614-
self.hir_to_def_index.insert(*hir_id, index);
615-
}
616593
}
617594

618595
if expansion != Mark::root() {

src/librustc/hir/map/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ impl<'hir> Map<'hir> {
252252
// FIXME(@ljedrz): replace the NodeId variant
253253
#[inline]
254254
pub fn local_def_id_from_hir_id(&self, hir_id: HirId) -> DefId {
255-
self.opt_local_def_id_from_hir_id(hir_id).unwrap_or_else(|| {
256-
let node_id = self.hir_to_node_id(hir_id);
255+
let node_id = self.hir_to_node_id(hir_id);
256+
self.opt_local_def_id(node_id).unwrap_or_else(|| {
257257
bug!("local_def_id_from_hir_id: no entry for `{:?}`, which has a map of `{:?}`",
258258
hir_id, self.find_entry(node_id))
259259
})
@@ -262,7 +262,8 @@ impl<'hir> Map<'hir> {
262262
// FIXME(@ljedrz): replace the NodeId variant
263263
#[inline]
264264
pub fn opt_local_def_id_from_hir_id(&self, hir_id: HirId) -> Option<DefId> {
265-
self.definitions.opt_local_def_id_from_hir_id(hir_id)
265+
let node_id = self.hir_to_node_id(hir_id);
266+
self.definitions.opt_local_def_id(node_id)
266267
}
267268

268269
#[inline]

0 commit comments

Comments
 (0)