Skip to content

Commit fa7582d

Browse files
Replace NodeId variant of read
1 parent 78b53db commit fa7582d

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

src/librustc/hir/map/mod.rs

+13-17
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,7 @@ impl<'hir> Map<'hir> {
190190
/// otherwise have had access to those contents, and hence needs a
191191
/// read recorded). If the function just returns a DefId or
192192
/// NodeId, no actual content was returned, so no read is needed.
193-
pub fn read(&self, id: NodeId) {
194-
let hir_id = self.node_to_hir_id(id);
195-
self.read_by_hir_id(hir_id);
196-
}
197-
198-
// FIXME(@ljedrz): replace the NodeId variant
199-
pub fn read_by_hir_id(&self, hir_id: HirId) {
193+
pub fn read(&self, hir_id: HirId) {
200194
if let Some(entry) = self.map.get(&hir_id) {
201195
self.dep_graph.read_index(entry.dep_node);
202196
} else {
@@ -402,23 +396,23 @@ impl<'hir> Map<'hir> {
402396
}
403397

404398
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem {
405-
self.read_by_hir_id(id.hir_id);
399+
self.read(id.hir_id);
406400

407401
// N.B., intentionally bypass `self.forest.krate()` so that we
408402
// do not trigger a read of the whole krate here
409403
self.forest.krate.trait_item(id)
410404
}
411405

412406
pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem {
413-
self.read_by_hir_id(id.hir_id);
407+
self.read(id.hir_id);
414408

415409
// N.B., intentionally bypass `self.forest.krate()` so that we
416410
// do not trigger a read of the whole krate here
417411
self.forest.krate.impl_item(id)
418412
}
419413

420414
pub fn body(&self, id: BodyId) -> &'hir Body {
421-
self.read_by_hir_id(id.hir_id);
415+
self.read(id.hir_id);
422416

423417
// N.B., intentionally bypass `self.forest.krate()` so that we
424418
// do not trigger a read of the whole krate here
@@ -551,7 +545,7 @@ impl<'hir> Map<'hir> {
551545
pub fn get_module(&self, module: DefId) -> (&'hir Mod, Span, HirId)
552546
{
553547
let hir_id = self.as_local_hir_id(module).unwrap();
554-
self.read_by_hir_id(hir_id);
548+
self.read(hir_id);
555549
match self.find_entry(hir_id).unwrap().node {
556550
Node::Item(&Item {
557551
span,
@@ -566,13 +560,15 @@ impl<'hir> Map<'hir> {
566560
pub fn visit_item_likes_in_module<V>(&self, module: DefId, visitor: &mut V)
567561
where V: ItemLikeVisitor<'hir>
568562
{
569-
let node_id = self.as_local_node_id(module).unwrap();
563+
let hir_id = self.as_local_hir_id(module).unwrap();
570564

571565
// Read the module so we'll be re-executed if new items
572566
// appear immediately under in the module. If some new item appears
573567
// in some nested item in the module, we'll be re-executed due to reads
574568
// in the expect_* calls the loops below
575-
self.read(node_id);
569+
self.read(hir_id);
570+
571+
let node_id = self.hir_to_node_id[&hir_id];
576572

577573
let module = &self.forest.krate.modules[&node_id];
578574

@@ -650,7 +646,7 @@ impl<'hir> Map<'hir> {
650646
}
651647
});
652648
if result.is_some() {
653-
self.read_by_hir_id(hir_id);
649+
self.read(hir_id);
654650
}
655651
result
656652
}
@@ -884,7 +880,7 @@ impl<'hir> Map<'hir> {
884880
if let Entry {
885881
node: Node::Item(Item { node: ItemKind::ForeignMod(ref nm), .. }), .. } = entry
886882
{
887-
self.read_by_hir_id(hir_id); // reveals some of the content of a node
883+
self.read(hir_id); // reveals some of the content of a node
888884
return nm.abi;
889885
}
890886
}
@@ -992,7 +988,7 @@ impl<'hir> Map<'hir> {
992988

993989
// FIXME(@ljedrz): replace the NodeId variant
994990
pub fn attrs_by_hir_id(&self, id: HirId) -> &'hir [ast::Attribute] {
995-
self.read_by_hir_id(id); // reveals attributes on the node
991+
self.read(id); // reveals attributes on the node
996992
let attrs = match self.find_entry(id).map(|entry| entry.node) {
997993
Some(Node::Local(l)) => Some(&l.attrs[..]),
998994
Some(Node::Item(i)) => Some(&i.attrs[..]),
@@ -1037,7 +1033,7 @@ impl<'hir> Map<'hir> {
10371033

10381034
// FIXME(@ljedrz): replace the NodeId variant
10391035
pub fn span_by_hir_id(&self, hir_id: HirId) -> Span {
1040-
self.read_by_hir_id(hir_id); // reveals span from node
1036+
self.read(hir_id); // reveals span from node
10411037
match self.find_entry(hir_id).map(|entry| entry.node) {
10421038
Some(Node::Item(item)) => item.span,
10431039
Some(Node::ForeignItem(foreign_item)) => foreign_item.span,

src/librustc_metadata/index_builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ macro_rules! read_hir {
185185
($t:ty) => {
186186
impl<'tcx> DepGraphRead for &'tcx $t {
187187
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
188-
tcx.hir().read_by_hir_id(self.hir_id);
188+
tcx.hir().read(self.hir_id);
189189
}
190190
}
191191
}
@@ -219,6 +219,6 @@ pub struct FromId<T>(pub hir::HirId, pub T);
219219

220220
impl<T> DepGraphRead for FromId<T> {
221221
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
222-
tcx.hir().read_by_hir_id(self.0);
222+
tcx.hir().read(self.0);
223223
}
224224
}

0 commit comments

Comments
 (0)