@@ -8,7 +8,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
8
8
use rustc_data_structures:: svh:: Svh ;
9
9
use rustc_data_structures:: sync:: { par_for_each_in, DynSend , DynSync } ;
10
10
use 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 } ;
12
12
use rustc_hir:: definitions:: { DefKey , DefPath , DefPathData , DefPathHash } ;
13
13
use rustc_hir:: intravisit:: { self , Visitor } ;
14
14
use rustc_hir:: * ;
@@ -148,7 +148,7 @@ impl<'hir> Map<'hir> {
148
148
}
149
149
150
150
#[ 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 {
152
152
self . tcx . hir_module_items ( module) . items ( )
153
153
}
154
154
@@ -169,8 +169,8 @@ impl<'hir> Map<'hir> {
169
169
}
170
170
171
171
#[ 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 ( ) )
174
174
}
175
175
176
176
/// Do not call this function directly. The query should be called.
@@ -529,8 +529,8 @@ impl<'hir> Map<'hir> {
529
529
self . krate_attrs ( ) . iter ( ) . any ( |attr| attr. has_name ( sym:: rustc_coherence_is_core) )
530
530
}
531
531
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 ( ) ) ;
534
534
match self . tcx . hir_owner ( hir_id. owner ) . map ( |o| o. node ) {
535
535
Some ( OwnerNode :: Item ( & Item { span, kind : ItemKind :: Mod ( ref m) , .. } ) ) => {
536
536
( m, span, hir_id)
@@ -542,7 +542,7 @@ impl<'hir> Map<'hir> {
542
542
543
543
/// Walks the contents of the local crate. See also `visit_all_item_likes_in_crate`.
544
544
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 ) ;
546
546
visitor. visit_mod ( top_mod, span, hir_id) ;
547
547
}
548
548
@@ -595,7 +595,7 @@ impl<'hir> Map<'hir> {
595
595
596
596
/// This method is the equivalent of `visit_all_item_likes_in_crate` but restricted to
597
597
/// 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 )
599
599
where
600
600
V : Visitor < ' hir > ,
601
601
{
@@ -618,17 +618,19 @@ impl<'hir> Map<'hir> {
618
618
}
619
619
}
620
620
621
- pub fn for_each_module ( self , mut f : impl FnMut ( LocalDefId ) ) {
621
+ pub fn for_each_module ( self , mut f : impl FnMut ( LocalModDefId ) ) {
622
622
let crate_items = self . tcx . hir_crate_items ( ( ) ) ;
623
623
for module in crate_items. submodules . iter ( ) {
624
- f ( module. def_id )
624
+ f ( LocalModDefId :: new_unchecked ( module. def_id ) )
625
625
}
626
626
}
627
627
628
628
#[ 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 ) {
630
630
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
+ } )
632
634
}
633
635
634
636
/// 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 {
1324
1326
}
1325
1327
}
1326
1328
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 {
1328
1330
let mut collector = ItemCollector :: new ( tcx, false ) ;
1329
1331
1330
1332
let ( hir_mod, span, hir_id) = tcx. hir ( ) . get_module ( module_id) ;
0 commit comments