@@ -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
@@ -894,11 +894,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
894
894
let resolution =
895
895
self . resolution ( module, key) . try_borrow_mut ( ) . map_err ( |_| ( Determined , Weak :: No ) ) ?; // This happens when there is a cycle of imports.
896
896
897
- debug ! ( ?resolution) ;
898
-
899
897
let check_usable = |this : & mut Self , binding : NameBinding < ' ra > | {
900
898
let usable = this. is_accessible_from ( binding. vis , parent_scope. module ) ;
901
- debug ! ( ?usable) ;
902
899
if usable { Ok ( binding) } else { Err ( ( Determined , Weak :: No ) ) }
903
900
} ;
904
901
@@ -924,7 +921,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
924
921
925
922
None // Continue to global scope
926
923
}
927
- ModuleScope :: Global => {
924
+ ModuleScope :: Globs => {
928
925
// If we are here, any primary `resolution.binding` is either a glob, None,
929
926
// or should be ignored.
930
927
let binding = resolution. glob_binding ;
@@ -958,7 +955,18 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
958
955
return Some ( Err ( ( Undetermined , Weak :: No ) ) ) ;
959
956
}
960
957
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`).
962
970
if let Some ( binding) = binding {
963
971
if binding. determined ( ) || ns == MacroNS || shadowing == Shadowing :: Restricted {
964
972
return Some ( check_usable ( this, binding) ) ;
@@ -971,9 +979,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
971
979
}
972
980
} ) ;
973
981
974
- match break_result {
975
- Some ( result) => return result,
976
- None => { }
982
+ if let Some ( result) = break_result {
983
+ return result;
977
984
}
978
985
979
986
// --- From now on we have no resolution. ---
0 commit comments