@@ -869,17 +869,19 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
869869 let resolution =
870870 self . resolution ( module, key) . try_borrow_mut ( ) . map_err ( |_| ( Determined , Weak :: No ) ) ?; // This happens when there is a cycle of imports.
871871
872- if let Some ( Finalize { path_span , report_private , .. } ) = finalize {
873- // If the primary binding is unusable, search further and return the shadowed glob
874- // binding if it exists. What we really want here is having two separate scopes in
875- // a module - one for non-globs and one for globs, but until that's done use this
876- // hack to avoid inconsistent resolution ICEs during import validation.
877- let binding = [ resolution. binding , resolution. shadowed_glob ] . into_iter ( ) . find_map (
878- |binding| match ( binding, ignore_binding) {
872+ // If the primary binding is unusable, search further and return the shadowed glob
873+ // binding if it exists. What we really want here is having two separate scopes in
874+ // a module - one for non-globs and one for globs, but until that's done use this
875+ // hack to avoid inconsistent resolution ICEs during import validation.
876+ let binding =
877+ [ resolution. binding , resolution. shadowed_glob ] . into_iter ( ) . find_map ( |binding| {
878+ match ( binding, ignore_binding) {
879879 ( Some ( binding) , Some ( ignored) ) if ptr:: eq ( binding, ignored) => None ,
880880 _ => binding,
881- } ,
882- ) ;
881+ }
882+ } ) ;
883+
884+ if let Some ( Finalize { path_span, report_private, .. } ) = finalize {
883885 let Some ( binding) = binding else {
884886 return Err ( ( Determined , Weak :: No ) ) ;
885887 } ;
@@ -927,15 +929,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
927929 }
928930
929931 let check_usable = |this : & mut Self , binding : & ' a NameBinding < ' a > | {
930- if let Some ( ignored) = ignore_binding && ptr:: eq ( binding, ignored) {
931- return Err ( ( Determined , Weak :: No ) ) ;
932- }
933932 let usable = this. is_accessible_from ( binding. vis , parent_scope. module ) ;
934933 if usable { Ok ( binding) } else { Err ( ( Determined , Weak :: No ) ) }
935934 } ;
936935
937936 // Items and single imports are not shadowable, if we have one, then it's determined.
938- if let Some ( binding) = resolution . binding {
937+ if let Some ( binding) = binding {
939938 if !binding. is_glob_import ( ) {
940939 return check_usable ( self , binding) ;
941940 }
@@ -952,6 +951,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
952951 if !self . is_accessible_from ( import_vis, parent_scope. module ) {
953952 continue ;
954953 }
954+ if let Some ( ignored) = ignore_binding &&
955+ let NameBindingKind :: Import { import, .. } = ignored. kind &&
956+ ptr:: eq ( import, & * * single_import) {
957+ // Ignore not just the binding itself, but if it has a shadowed_glob,
958+ // ignore that, too, because this loop is supposed to only process
959+ // named imports.
960+ continue ;
961+ }
955962 let Some ( module) = single_import. imported_module . get ( ) else {
956963 return Err ( ( Undetermined , Weak :: No ) ) ;
957964 } ;
@@ -989,7 +996,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
989996 // and prohibit access to macro-expanded `macro_export` macros instead (unless restricted
990997 // shadowing is enabled, see `macro_expanded_macro_export_errors`).
991998 let unexpanded_macros = !module. unexpanded_invocations . borrow ( ) . is_empty ( ) ;
992- if let Some ( binding) = resolution . binding {
999+ if let Some ( binding) = binding {
9931000 if !unexpanded_macros || ns == MacroNS || restricted_shadowing {
9941001 return check_usable ( self , binding) ;
9951002 } else {
0 commit comments