@@ -181,7 +181,7 @@ impl<'hir> Iterator for ParentHirIterator<'_, 'hir> {
181
181
}
182
182
183
183
self . current_id = parent_id;
184
- if let Some ( entry) = self . map . find_entry ( parent_id) {
184
+ if let Some ( entry) = self . map . find_and_read_entry ( parent_id) {
185
185
return Some ( ( parent_id, entry. node ) ) ;
186
186
}
187
187
// If this `HirId` doesn't have an `Entry`, skip it and look for its `parent_id`.
@@ -381,6 +381,12 @@ impl<'hir> Map<'hir> {
381
381
self . lookup ( id) . cloned ( )
382
382
}
383
383
384
+ fn find_and_read_entry ( & self , id : HirId ) -> Option < Entry < ' hir > > {
385
+ let entry = self . find_entry ( id) ;
386
+ entry. map ( |e| self . dep_graph . read_index ( e. dep_node ) ) ;
387
+ entry
388
+ }
389
+
384
390
pub fn item ( & self , id : HirId ) -> & ' hir Item < ' hir > {
385
391
self . read ( id) ;
386
392
@@ -414,15 +420,15 @@ impl<'hir> Map<'hir> {
414
420
}
415
421
416
422
pub fn fn_decl_by_hir_id ( & self , hir_id : HirId ) -> Option < & ' hir FnDecl < ' hir > > {
417
- if let Some ( entry) = self . find_entry ( hir_id) {
423
+ if let Some ( entry) = self . find_and_read_entry ( hir_id) {
418
424
entry. fn_decl ( )
419
425
} else {
420
426
bug ! ( "no entry for hir_id `{}`" , hir_id)
421
427
}
422
428
}
423
429
424
430
pub fn fn_sig_by_hir_id ( & self , hir_id : HirId ) -> Option < & ' hir FnSig < ' hir > > {
425
- if let Some ( entry) = self . find_entry ( hir_id) {
431
+ if let Some ( entry) = self . find_and_read_entry ( hir_id) {
426
432
entry. fn_sig ( )
427
433
} else {
428
434
bug ! ( "no entry for hir_id `{}`" , hir_id)
@@ -612,7 +618,12 @@ impl<'hir> Map<'hir> {
612
618
if self . dep_graph . is_fully_enabled ( ) {
613
619
let hir_id_owner = hir_id. owner ;
614
620
let def_path_hash = self . definitions . def_path_hash ( hir_id_owner) ;
615
- self . dep_graph . read ( def_path_hash. to_dep_node ( DepKind :: HirBody ) ) ;
621
+ let kind = if hir_id. local_id == ItemLocalId :: from_u32_const ( 0 ) {
622
+ DepKind :: Hir
623
+ } else {
624
+ DepKind :: HirBody
625
+ } ;
626
+ self . dep_graph . read ( def_path_hash. to_dep_node ( kind) ) ;
616
627
}
617
628
618
629
self . find_entry ( hir_id) . and_then ( |x| x. parent_node ( ) ) . unwrap_or ( hir_id)
@@ -654,7 +665,7 @@ impl<'hir> Map<'hir> {
654
665
655
666
/// Wether `hir_id` corresponds to a `mod` or a crate.
656
667
pub fn is_hir_id_module ( & self , hir_id : HirId ) -> bool {
657
- match self . lookup ( hir_id) {
668
+ match self . find_and_read_entry ( hir_id) {
658
669
Some ( Entry { node : Node :: Item ( Item { kind : ItemKind :: Mod ( _) , .. } ) , .. } )
659
670
| Some ( Entry { node : Node :: Crate , .. } ) => true ,
660
671
_ => false ,
@@ -1150,7 +1161,7 @@ impl<'a> NodesMatchingSuffix<'a> {
1150
1161
}
1151
1162
1152
1163
fn matches_suffix ( & self , hir : HirId ) -> bool {
1153
- let name = match self . map . find_entry ( hir) . map ( |entry| entry. node ) {
1164
+ let name = match self . map . find_and_read_entry ( hir) . map ( |entry| entry. node ) {
1154
1165
Some ( Node :: Item ( n) ) => n. name ( ) ,
1155
1166
Some ( Node :: ForeignItem ( n) ) => n. name ( ) ,
1156
1167
Some ( Node :: TraitItem ( n) ) => n. name ( ) ,
0 commit comments