@@ -508,11 +508,7 @@ impl EmbargoVisitor<'tcx> {
508
508
}
509
509
}
510
510
511
- fn update_macro_reachable_mod (
512
- & mut self ,
513
- reachable_mod : hir:: HirId ,
514
- defining_mod : DefId ,
515
- ) {
511
+ fn update_macro_reachable_mod ( & mut self , reachable_mod : hir:: HirId , defining_mod : DefId ) {
516
512
let module_def_id = self . tcx . hir ( ) . local_def_id ( reachable_mod) ;
517
513
let module = self . tcx . hir ( ) . get_module ( module_def_id) . 0 ;
518
514
for item_id in & module. item_ids {
@@ -524,19 +520,13 @@ impl EmbargoVisitor<'tcx> {
524
520
self . update_macro_reachable_def ( hir_id, def_kind, vis, defining_mod) ;
525
521
}
526
522
}
527
-
528
523
if let Some ( exports) = self . tcx . module_exports ( module_def_id) {
529
524
for export in exports {
530
525
if export. vis . is_accessible_from ( defining_mod, self . tcx ) {
531
526
if let Res :: Def ( def_kind, def_id) = export. res {
532
527
let vis = def_id_visibility ( self . tcx , def_id) . 0 ;
533
528
if let Some ( hir_id) = self . tcx . hir ( ) . as_local_hir_id ( def_id) {
534
- self . update_macro_reachable_def (
535
- hir_id,
536
- def_kind,
537
- vis,
538
- defining_mod,
539
- ) ;
529
+ self . update_macro_reachable_def ( hir_id, def_kind, vis, defining_mod) ;
540
530
}
541
531
}
542
532
}
@@ -892,10 +882,14 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
892
882
self . tcx . hir ( ) . local_def_id ( md. hir_id )
893
883
) . unwrap ( ) ;
894
884
let mut module_id = self . tcx . hir ( ) . as_local_hir_id ( macro_module_def_id) . unwrap ( ) ;
885
+ if !self . tcx . hir ( ) . is_hir_id_module ( module_id) {
886
+ // `module_id` doesn't correspond to a `mod`, return early (#63164).
887
+ return ;
888
+ }
895
889
let level = if md. vis . node . is_pub ( ) { self . get ( module_id) } else { None } ;
896
890
let new_level = self . update ( md. hir_id , level) ;
897
891
if new_level. is_none ( ) {
898
- return
892
+ return ;
899
893
}
900
894
901
895
loop {
0 commit comments