@@ -8,7 +8,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
88use rustc_data_structures:: svh:: Svh ;
99use rustc_data_structures:: sync:: { par_for_each_in, DynSend , DynSync } ;
1010use rustc_hir:: def:: { DefKind , Res } ;
11- use rustc_hir:: def_id:: { DefId , LocalDefId , CRATE_DEF_ID , LOCAL_CRATE } ;
11+ use rustc_hir:: def_id:: { DefId , LocalDefId , LocalModDefId , LOCAL_CRATE } ;
1212use rustc_hir:: definitions:: { DefKey , DefPath , DefPathData , DefPathHash } ;
1313use rustc_hir:: intravisit:: { self , Visitor } ;
1414use rustc_hir:: * ;
@@ -148,7 +148,7 @@ impl<'hir> Map<'hir> {
148148 }
149149
150150 #[ inline]
151- pub fn module_items ( self , module : LocalDefId ) -> impl Iterator < Item = ItemId > + ' hir {
151+ pub fn module_items ( self , module : LocalModDefId ) -> impl Iterator < Item = ItemId > + ' hir {
152152 self . tcx . hir_module_items ( module) . items ( )
153153 }
154154
@@ -169,8 +169,8 @@ impl<'hir> Map<'hir> {
169169 }
170170
171171 #[ inline]
172- pub fn local_def_id_to_hir_id ( self , def_id : LocalDefId ) -> HirId {
173- self . tcx . local_def_id_to_hir_id ( def_id)
172+ pub fn local_def_id_to_hir_id ( self , def_id : impl Into < LocalDefId > ) -> HirId {
173+ self . tcx . local_def_id_to_hir_id ( def_id. into ( ) )
174174 }
175175
176176 /// Do not call this function directly. The query should be called.
@@ -529,8 +529,8 @@ impl<'hir> Map<'hir> {
529529 self . krate_attrs ( ) . iter ( ) . any ( |attr| attr. has_name ( sym:: rustc_coherence_is_core) )
530530 }
531531
532- pub fn get_module ( self , module : LocalDefId ) -> ( & ' hir Mod < ' hir > , Span , HirId ) {
533- let hir_id = HirId :: make_owner ( module) ;
532+ pub fn get_module ( self , module : LocalModDefId ) -> ( & ' hir Mod < ' hir > , Span , HirId ) {
533+ let hir_id = HirId :: make_owner ( module. to_local_def_id ( ) ) ;
534534 match self . tcx . hir_owner ( hir_id. owner ) . map ( |o| o. node ) {
535535 Some ( OwnerNode :: Item ( & Item { span, kind : ItemKind :: Mod ( ref m) , .. } ) ) => {
536536 ( m, span, hir_id)
@@ -542,7 +542,7 @@ impl<'hir> Map<'hir> {
542542
543543 /// Walks the contents of the local crate. See also `visit_all_item_likes_in_crate`.
544544 pub fn walk_toplevel_module ( self , visitor : & mut impl Visitor < ' hir > ) {
545- let ( top_mod, span, hir_id) = self . get_module ( CRATE_DEF_ID ) ;
545+ let ( top_mod, span, hir_id) = self . get_module ( LocalModDefId :: CRATE_DEF_ID ) ;
546546 visitor. visit_mod ( top_mod, span, hir_id) ;
547547 }
548548
@@ -595,7 +595,7 @@ impl<'hir> Map<'hir> {
595595
596596 /// This method is the equivalent of `visit_all_item_likes_in_crate` but restricted to
597597 /// item-likes in a single module.
598- pub fn visit_item_likes_in_module < V > ( self , module : LocalDefId , visitor : & mut V )
598+ pub fn visit_item_likes_in_module < V > ( self , module : LocalModDefId , visitor : & mut V )
599599 where
600600 V : Visitor < ' hir > ,
601601 {
@@ -618,17 +618,19 @@ impl<'hir> Map<'hir> {
618618 }
619619 }
620620
621- pub fn for_each_module ( self , mut f : impl FnMut ( LocalDefId ) ) {
621+ pub fn for_each_module ( self , mut f : impl FnMut ( LocalModDefId ) ) {
622622 let crate_items = self . tcx . hir_crate_items ( ( ) ) ;
623623 for module in crate_items. submodules . iter ( ) {
624- f ( module. def_id )
624+ f ( LocalModDefId :: new_unchecked ( module. def_id ) )
625625 }
626626 }
627627
628628 #[ inline]
629- pub fn par_for_each_module ( self , f : impl Fn ( LocalDefId ) + DynSend + DynSync ) {
629+ pub fn par_for_each_module ( self , f : impl Fn ( LocalModDefId ) + DynSend + DynSync ) {
630630 let crate_items = self . tcx . hir_crate_items ( ( ) ) ;
631- par_for_each_in ( & crate_items. submodules [ ..] , |module| f ( module. def_id ) )
631+ par_for_each_in ( & crate_items. submodules [ ..] , |module| {
632+ f ( LocalModDefId :: new_unchecked ( module. def_id ) )
633+ } )
632634 }
633635
634636 /// Returns an iterator for the nodes in the ancestor tree of the `current_id`
@@ -1324,7 +1326,7 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
13241326 }
13251327}
13261328
1327- pub ( super ) fn hir_module_items ( tcx : TyCtxt < ' _ > , module_id : LocalDefId ) -> ModuleItems {
1329+ pub ( super ) fn hir_module_items ( tcx : TyCtxt < ' _ > , module_id : LocalModDefId ) -> ModuleItems {
13281330 let mut collector = ItemCollector :: new ( tcx, false ) ;
13291331
13301332 let ( hir_mod, span, hir_id) = tcx. hir ( ) . get_module ( module_id) ;
0 commit comments