@@ -224,7 +224,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
224
224
}
225
225
226
226
#[ instrument( skip( self , visitor) , level = "debug" ) ]
227
- pub ( crate ) fn visit_module_scopes < T > (
227
+ fn visit_module_scopes < T > (
228
228
& mut self ,
229
229
ns : Namespace ,
230
230
mut visitor : impl FnMut ( & mut Self , ModuleScope ) -> Option < T > ,
@@ -236,8 +236,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
236
236
}
237
237
238
238
scope = match scope {
239
- ModuleScope :: NonGlobal => ModuleScope :: Global ,
240
- ModuleScope :: Global => break , // nowhere else to search
239
+ ModuleScope :: NonGlobal => ModuleScope :: Globs ,
240
+ ModuleScope :: Globs => break , // nowhere else to search
241
241
} ;
242
242
}
243
243
@@ -893,11 +893,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
893
893
let resolution =
894
894
self . resolution ( module, key) . try_borrow_mut ( ) . map_err ( |_| ( Determined , Weak :: No ) ) ?; // This happens when there is a cycle of imports.
895
895
896
- debug ! ( ?resolution) ;
897
-
898
896
let check_usable = |this : & mut Self , binding : NameBinding < ' ra > | {
899
897
let usable = this. is_accessible_from ( binding. vis , parent_scope. module ) ;
900
- debug ! ( ?usable) ;
901
898
if usable { Ok ( binding) } else { Err ( ( Determined , Weak :: No ) ) }
902
899
} ;
903
900
@@ -923,7 +920,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
923
920
924
921
None // Continue to global scope
925
922
}
926
- ModuleScope :: Global => {
923
+ ModuleScope :: Globs => {
927
924
// If we are here, any primary `resolution.binding` is either a glob, None,
928
925
// or should be ignored.
929
926
let binding = resolution. glob_binding ;
@@ -957,7 +954,18 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
957
954
return Some ( Err ( ( Undetermined , Weak :: No ) ) ) ;
958
955
}
959
956
960
- // A glob resolution is determined if it cannot be shadowed by a macro expansion.
957
+ // So we have a resolution that's from a glob import. This resolution is determined
958
+ // if it cannot be shadowed by some new item/import expanded from a macro.
959
+ // This happens either if there are no unexpanded macros, or expanded names cannot
960
+ // shadow globs (that happens in macro namespace or with restricted shadowing).
961
+ //
962
+ // Additionally, any macro in any module can plant names in the root module if it creates
963
+ // `macro_export` macros, so the root module effectively has unresolved invocations if any
964
+ // module has unresolved invocations.
965
+ // However, it causes resolution/expansion to stuck too often (#53144), so, to make
966
+ // progress, we have to ignore those potential unresolved invocations from other modules
967
+ // and prohibit access to macro-expanded `macro_export` macros instead (unless restricted
968
+ // shadowing is enabled, see `macro_expanded_macro_export_errors`).
961
969
if let Some ( binding) = binding {
962
970
if binding. determined ( ) || ns == MacroNS || shadowing == Shadowing :: Restricted {
963
971
return Some ( check_usable ( this, binding) ) ;
@@ -970,9 +978,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
970
978
}
971
979
} ) ;
972
980
973
- match break_result {
974
- Some ( result) => return result,
975
- None => { }
981
+ if let Some ( result) = break_result {
982
+ return result;
976
983
}
977
984
978
985
// --- From now on we have no resolution. ---
0 commit comments