@@ -224,7 +224,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
224224 }
225225
226226 #[ instrument( skip( self , visitor) , level = "debug" ) ]
227- pub ( crate ) fn visit_module_scopes < T > (
227+ fn visit_module_scopes < T > (
228228 & mut self ,
229229 ns : Namespace ,
230230 mut visitor : impl FnMut ( & mut Self , ModuleScope ) -> Option < T > ,
@@ -236,8 +236,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
236236 }
237237
238238 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
241241 } ;
242242 }
243243
@@ -894,11 +894,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
894894 let resolution =
895895 self . resolution ( module, key) . try_borrow_mut ( ) . map_err ( |_| ( Determined , Weak :: No ) ) ?; // This happens when there is a cycle of imports.
896896
897- debug ! ( ?resolution) ;
898-
899897 let check_usable = |this : & mut Self , binding : NameBinding < ' ra > | {
900898 let usable = this. is_accessible_from ( binding. vis , parent_scope. module ) ;
901- debug ! ( ?usable) ;
902899 if usable { Ok ( binding) } else { Err ( ( Determined , Weak :: No ) ) }
903900 } ;
904901
@@ -924,7 +921,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
924921
925922 None // Continue to global scope
926923 }
927- ModuleScope :: Global => {
924+ ModuleScope :: Globs => {
928925 // If we are here, any primary `resolution.binding` is either a glob, None,
929926 // or should be ignored.
930927 let binding = resolution. glob_binding ;
@@ -958,7 +955,18 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
958955 return Some ( Err ( ( Undetermined , Weak :: No ) ) ) ;
959956 }
960957
961- // A glob resolution is determined if it cannot be shadowed by a macro expansion.
958+ // So we have a resolution that's from a glob import. This resolution is determined
959+ // if it cannot be shadowed by some new item/import expanded from a macro.
960+ // This happens either if there are no unexpanded macros, or expanded names cannot
961+ // shadow globs (that happens in macro namespace or with restricted shadowing).
962+ //
963+ // Additionally, any macro in any module can plant names in the root module if it creates
964+ // `macro_export` macros, so the root module effectively has unresolved invocations if any
965+ // module has unresolved invocations.
966+ // However, it causes resolution/expansion to stuck too often (#53144), so, to make
967+ // progress, we have to ignore those potential unresolved invocations from other modules
968+ // and prohibit access to macro-expanded `macro_export` macros instead (unless restricted
969+ // shadowing is enabled, see `macro_expanded_macro_export_errors`).
962970 if let Some ( binding) = binding {
963971 if binding. determined ( ) || ns == MacroNS || shadowing == Shadowing :: Restricted {
964972 return Some ( check_usable ( this, binding) ) ;
@@ -971,9 +979,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
971979 }
972980 } ) ;
973981
974- match break_result {
975- Some ( result) => return result,
976- None => { }
982+ if let Some ( result) = break_result {
983+ return result;
977984 }
978985
979986 // --- From now on we have no resolution. ---
0 commit comments