@@ -190,13 +190,7 @@ impl<'hir> Map<'hir> {
190
190
/// otherwise have had access to those contents, and hence needs a
191
191
/// read recorded). If the function just returns a DefId or
192
192
/// 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 ) {
200
194
if let Some ( entry) = self . map . get ( & hir_id) {
201
195
self . dep_graph . read_index ( entry. dep_node ) ;
202
196
} else {
@@ -402,23 +396,23 @@ impl<'hir> Map<'hir> {
402
396
}
403
397
404
398
pub fn trait_item ( & self , id : TraitItemId ) -> & ' hir TraitItem {
405
- self . read_by_hir_id ( id. hir_id ) ;
399
+ self . read ( id. hir_id ) ;
406
400
407
401
// N.B., intentionally bypass `self.forest.krate()` so that we
408
402
// do not trigger a read of the whole krate here
409
403
self . forest . krate . trait_item ( id)
410
404
}
411
405
412
406
pub fn impl_item ( & self , id : ImplItemId ) -> & ' hir ImplItem {
413
- self . read_by_hir_id ( id. hir_id ) ;
407
+ self . read ( id. hir_id ) ;
414
408
415
409
// N.B., intentionally bypass `self.forest.krate()` so that we
416
410
// do not trigger a read of the whole krate here
417
411
self . forest . krate . impl_item ( id)
418
412
}
419
413
420
414
pub fn body ( & self , id : BodyId ) -> & ' hir Body {
421
- self . read_by_hir_id ( id. hir_id ) ;
415
+ self . read ( id. hir_id ) ;
422
416
423
417
// N.B., intentionally bypass `self.forest.krate()` so that we
424
418
// do not trigger a read of the whole krate here
@@ -551,7 +545,7 @@ impl<'hir> Map<'hir> {
551
545
pub fn get_module ( & self , module : DefId ) -> ( & ' hir Mod , Span , HirId )
552
546
{
553
547
let hir_id = self . as_local_hir_id ( module) . unwrap ( ) ;
554
- self . read_by_hir_id ( hir_id) ;
548
+ self . read ( hir_id) ;
555
549
match self . find_entry ( hir_id) . unwrap ( ) . node {
556
550
Node :: Item ( & Item {
557
551
span,
@@ -566,13 +560,15 @@ impl<'hir> Map<'hir> {
566
560
pub fn visit_item_likes_in_module < V > ( & self , module : DefId , visitor : & mut V )
567
561
where V : ItemLikeVisitor < ' hir >
568
562
{
569
- let node_id = self . as_local_node_id ( module) . unwrap ( ) ;
563
+ let hir_id = self . as_local_hir_id ( module) . unwrap ( ) ;
570
564
571
565
// Read the module so we'll be re-executed if new items
572
566
// appear immediately under in the module. If some new item appears
573
567
// in some nested item in the module, we'll be re-executed due to reads
574
568
// 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] ;
576
572
577
573
let module = & self . forest . krate . modules [ & node_id] ;
578
574
@@ -650,7 +646,7 @@ impl<'hir> Map<'hir> {
650
646
}
651
647
} ) ;
652
648
if result. is_some ( ) {
653
- self . read_by_hir_id ( hir_id) ;
649
+ self . read ( hir_id) ;
654
650
}
655
651
result
656
652
}
@@ -884,7 +880,7 @@ impl<'hir> Map<'hir> {
884
880
if let Entry {
885
881
node : Node :: Item ( Item { node : ItemKind :: ForeignMod ( ref nm) , .. } ) , .. } = entry
886
882
{
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
888
884
return nm. abi ;
889
885
}
890
886
}
@@ -992,7 +988,7 @@ impl<'hir> Map<'hir> {
992
988
993
989
// FIXME(@ljedrz): replace the NodeId variant
994
990
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
996
992
let attrs = match self . find_entry ( id) . map ( |entry| entry. node ) {
997
993
Some ( Node :: Local ( l) ) => Some ( & l. attrs [ ..] ) ,
998
994
Some ( Node :: Item ( i) ) => Some ( & i. attrs [ ..] ) ,
@@ -1037,7 +1033,7 @@ impl<'hir> Map<'hir> {
1037
1033
1038
1034
// FIXME(@ljedrz): replace the NodeId variant
1039
1035
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
1041
1037
match self . find_entry ( hir_id) . map ( |entry| entry. node ) {
1042
1038
Some ( Node :: Item ( item) ) => item. span ,
1043
1039
Some ( Node :: ForeignItem ( foreign_item) ) => foreign_item. span ,
0 commit comments