@@ -82,32 +82,40 @@ impl<'ra> ImportResolutionOutputs<'ra> {
82
82
ImportKind :: Single { target, bindings, .. } ,
83
83
SideEffectBindings :: Single { import_bindings } ,
84
84
) => {
85
- for ( ns , pending_binding ) in import_bindings . into_iter_with ( ) {
86
- match pending_binding {
85
+ r . per_ns ( |this , ns| {
86
+ match import_bindings [ ns ] {
87
87
PendingBinding :: Ready ( Some ( binding) ) => {
88
88
if binding. is_assoc_item ( )
89
- && !r . tcx . features ( ) . import_trait_associated_functions ( )
89
+ && !this . tcx . features ( ) . import_trait_associated_functions ( )
90
90
{
91
91
feature_err (
92
- r . tcx . sess ,
92
+ this . tcx . sess ,
93
93
sym:: import_trait_associated_functions,
94
94
import. span ,
95
95
"`use` associated items of traits is unstable" ,
96
96
)
97
97
. emit ( ) ;
98
98
}
99
- r . define_binding_local ( parent, * target, ns, binding) ;
99
+ this . define_binding_local ( parent, * target, ns, binding) ;
100
100
}
101
101
PendingBinding :: Ready ( None ) => {
102
- let key = BindingKey :: new ( * target, ns) ;
103
- r. update_local_resolution ( parent, key, false , |_, resolution| {
104
- resolution. single_imports . swap_remove ( & import) ;
105
- } ) ;
102
+ // Don't remove underscores from `single_imports`, they were never added.
103
+ if target. name != kw:: Underscore {
104
+ let key = BindingKey :: new ( * target, ns) ;
105
+ this. update_local_resolution (
106
+ parent,
107
+ key,
108
+ false ,
109
+ |_, resolution| {
110
+ resolution. single_imports . swap_remove ( & import) ;
111
+ } ,
112
+ ) ;
113
+ }
106
114
}
107
115
_ => { }
108
116
}
109
- bindings[ ns] . set ( pending_binding ) ;
110
- }
117
+ bindings[ ns] . set ( import_bindings [ ns ] ) ;
118
+ } ) ;
111
119
}
112
120
( ImportKind :: Glob { id, .. } , SideEffectBindings :: Glob { import_bindings } ) => {
113
121
let ModuleOrUniformRoot :: Module ( module) = import. imported_module . get ( ) . unwrap ( )
@@ -973,7 +981,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
973
981
}
974
982
} ;
975
983
976
- let ( source, target , bindings, type_ns_only) = match import. kind {
984
+ let ( source, _ , bindings, type_ns_only) = match import. kind {
977
985
ImportKind :: Single { source, target, ref bindings, type_ns_only, .. } => {
978
986
( source, target, bindings, type_ns_only)
979
987
}
@@ -989,7 +997,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
989
997
_ => unreachable ! ( ) ,
990
998
} ;
991
999
992
- let mut import_bindings = PerNS :: default ( ) ;
1000
+ let mut import_bindings = bindings . clone ( ) . map ( |b| b . get ( ) ) ;
993
1001
let mut indeterminate_count = 0 ;
994
1002
self . reborrow ( ) . per_ns_cm ( |this, ns| {
995
1003
if !type_ns_only || ns == TypeNS {
@@ -1009,16 +1017,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1009
1017
let imported_binding = this. import ( binding, import) ;
1010
1018
PendingBinding :: Ready ( Some ( imported_binding) )
1011
1019
}
1012
- Err ( Determinacy :: Determined ) => {
1013
- // Don't remove underscores from `single_imports`, they were never added.
1014
- if target. name == kw:: Underscore {
1015
- return ;
1016
- }
1017
- PendingBinding :: Ready ( None )
1018
- }
1020
+ Err ( Determinacy :: Determined ) => PendingBinding :: Ready ( None ) ,
1019
1021
Err ( Determinacy :: Undetermined ) => {
1020
1022
indeterminate_count += 1 ;
1021
- return ;
1023
+ PendingBinding :: Pending
1022
1024
}
1023
1025
} ;
1024
1026
import_bindings[ ns] = pending_binding;
0 commit comments