@@ -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 ( )
@@ -976,7 +984,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
976
984
}
977
985
} ;
978
986
979
- let ( source, target , bindings, type_ns_only) = match import. kind {
987
+ let ( source, _ , bindings, type_ns_only) = match import. kind {
980
988
ImportKind :: Single { source, target, ref bindings, type_ns_only, .. } => {
981
989
( source, target, bindings, type_ns_only)
982
990
}
@@ -992,7 +1000,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
992
1000
_ => unreachable ! ( ) ,
993
1001
} ;
994
1002
995
- let mut import_bindings = PerNS :: default ( ) ;
1003
+ let mut import_bindings = bindings . clone ( ) . map ( |b| b . get ( ) ) ;
996
1004
let mut indeterminate_count = 0 ;
997
1005
self . reborrow ( ) . per_ns_cm ( |this, ns| {
998
1006
if !type_ns_only || ns == TypeNS {
@@ -1012,16 +1020,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1012
1020
let imported_binding = this. import ( binding, import) ;
1013
1021
PendingBinding :: Ready ( Some ( imported_binding) )
1014
1022
}
1015
- Err ( Determinacy :: Determined ) => {
1016
- // Don't remove underscores from `single_imports`, they were never added.
1017
- if target. name == kw:: Underscore {
1018
- return ;
1019
- }
1020
- PendingBinding :: Ready ( None )
1021
- }
1023
+ Err ( Determinacy :: Determined ) => PendingBinding :: Ready ( None ) ,
1022
1024
Err ( Determinacy :: Undetermined ) => {
1023
1025
indeterminate_count += 1 ;
1024
- return ;
1026
+ PendingBinding :: Pending
1025
1027
}
1026
1028
} ;
1027
1029
import_bindings[ ns] = pending_binding;
0 commit comments