@@ -869,17 +869,19 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
869
869
let resolution =
870
870
self . resolution ( module, key) . try_borrow_mut ( ) . map_err ( |_| ( Determined , Weak :: No ) ) ?; // This happens when there is a cycle of imports.
871
871
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) {
879
879
( Some ( binding) , Some ( ignored) ) if ptr:: eq ( binding, ignored) => None ,
880
880
_ => binding,
881
- } ,
882
- ) ;
881
+ }
882
+ } ) ;
883
+
884
+ if let Some ( Finalize { path_span, report_private, .. } ) = finalize {
883
885
let Some ( binding) = binding else {
884
886
return Err ( ( Determined , Weak :: No ) ) ;
885
887
} ;
@@ -927,15 +929,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
927
929
}
928
930
929
931
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
- }
933
932
let usable = this. is_accessible_from ( binding. vis , parent_scope. module ) ;
934
933
if usable { Ok ( binding) } else { Err ( ( Determined , Weak :: No ) ) }
935
934
} ;
936
935
937
936
// 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 {
939
938
if !binding. is_glob_import ( ) {
940
939
return check_usable ( self , binding) ;
941
940
}
@@ -952,6 +951,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
952
951
if !self . is_accessible_from ( import_vis, parent_scope. module ) {
953
952
continue ;
954
953
}
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
+ }
955
962
let Some ( module) = single_import. imported_module . get ( ) else {
956
963
return Err ( ( Undetermined , Weak :: No ) ) ;
957
964
} ;
@@ -989,7 +996,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
989
996
// and prohibit access to macro-expanded `macro_export` macros instead (unless restricted
990
997
// shadowing is enabled, see `macro_expanded_macro_export_errors`).
991
998
let unexpanded_macros = !module. unexpanded_invocations . borrow ( ) . is_empty ( ) ;
992
- if let Some ( binding) = resolution . binding {
999
+ if let Some ( binding) = binding {
993
1000
if !unexpanded_macros || ns == MacroNS || restricted_shadowing {
994
1001
return check_usable ( self , binding) ;
995
1002
} else {
0 commit comments