@@ -181,7 +181,7 @@ impl<'hir> Iterator for ParentHirIterator<'_, 'hir> {
181181 }
182182
183183 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) {
185185 return Some ( ( parent_id, entry. node ) ) ;
186186 }
187187 // If this `HirId` doesn't have an `Entry`, skip it and look for its `parent_id`.
@@ -381,6 +381,12 @@ impl<'hir> Map<'hir> {
381381 self . lookup ( id) . cloned ( )
382382 }
383383
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+
384390 pub fn item ( & self , id : HirId ) -> & ' hir Item < ' hir > {
385391 self . read ( id) ;
386392
@@ -414,15 +420,15 @@ impl<'hir> Map<'hir> {
414420 }
415421
416422 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) {
418424 entry. fn_decl ( )
419425 } else {
420426 bug ! ( "no entry for hir_id `{}`" , hir_id)
421427 }
422428 }
423429
424430 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) {
426432 entry. fn_sig ( )
427433 } else {
428434 bug ! ( "no entry for hir_id `{}`" , hir_id)
@@ -612,7 +618,12 @@ impl<'hir> Map<'hir> {
612618 if self . dep_graph . is_fully_enabled ( ) {
613619 let hir_id_owner = hir_id. owner ;
614620 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) ) ;
616627 }
617628
618629 self . find_entry ( hir_id) . and_then ( |x| x. parent_node ( ) ) . unwrap_or ( hir_id)
@@ -654,7 +665,7 @@ impl<'hir> Map<'hir> {
654665
655666 /// Wether `hir_id` corresponds to a `mod` or a crate.
656667 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) {
658669 Some ( Entry { node : Node :: Item ( Item { kind : ItemKind :: Mod ( _) , .. } ) , .. } )
659670 | Some ( Entry { node : Node :: Crate , .. } ) => true ,
660671 _ => false ,
@@ -1150,7 +1161,7 @@ impl<'a> NodesMatchingSuffix<'a> {
11501161 }
11511162
11521163 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 ) {
11541165 Some ( Node :: Item ( n) ) => n. name ( ) ,
11551166 Some ( Node :: ForeignItem ( n) ) => n. name ( ) ,
11561167 Some ( Node :: TraitItem ( n) ) => n. name ( ) ,
0 commit comments