@@ -175,8 +175,7 @@ impl<'a> Resolver<'a> {
175
175
ident : Ident ,
176
176
ns : Namespace ,
177
177
parent_scope : & ParentScope < ' a > ,
178
- record_used : bool ,
179
- path_span : Span ,
178
+ record_used : Option < Span > ,
180
179
) -> Result < & ' a NameBinding < ' a > , Determinacy > {
181
180
self . resolve_ident_in_module_unadjusted_ext (
182
181
module,
@@ -185,7 +184,6 @@ impl<'a> Resolver<'a> {
185
184
parent_scope,
186
185
false ,
187
186
record_used,
188
- path_span,
189
187
)
190
188
. map_err ( |( determinacy, _) | determinacy)
191
189
}
@@ -199,8 +197,7 @@ impl<'a> Resolver<'a> {
199
197
ns : Namespace ,
200
198
parent_scope : & ParentScope < ' a > ,
201
199
restricted_shadowing : bool ,
202
- record_used : bool ,
203
- path_span : Span ,
200
+ record_used : Option < Span > ,
204
201
) -> Result < & ' a NameBinding < ' a > , ( Determinacy , Weak ) > {
205
202
let module = match module {
206
203
ModuleOrUniformRoot :: Module ( module) => module,
@@ -211,16 +208,16 @@ impl<'a> Resolver<'a> {
211
208
ScopeSet :: AbsolutePath ( ns) ,
212
209
parent_scope,
213
210
record_used,
214
- record_used,
215
- path_span,
211
+ record_used. is_some ( ) ,
216
212
) ;
217
213
return binding. map_err ( |determinacy| ( determinacy, Weak :: No ) ) ;
218
214
}
219
215
ModuleOrUniformRoot :: ExternPrelude => {
220
216
assert ! ( !restricted_shadowing) ;
221
217
return if ns != TypeNS {
222
218
Err ( ( Determined , Weak :: No ) )
223
- } else if let Some ( binding) = self . extern_prelude_get ( ident, !record_used) {
219
+ } else if let Some ( binding) = self . extern_prelude_get ( ident, record_used. is_none ( ) )
220
+ {
224
221
Ok ( binding)
225
222
} else if !self . graph_root . unexpanded_invocations . borrow ( ) . is_empty ( ) {
226
223
// Macro-expanded `extern crate` items can add names to extern prelude.
@@ -251,8 +248,7 @@ impl<'a> Resolver<'a> {
251
248
scopes,
252
249
parent_scope,
253
250
record_used,
254
- record_used,
255
- path_span,
251
+ record_used. is_some ( ) ,
256
252
) ;
257
253
return binding. map_err ( |determinacy| ( determinacy, Weak :: No ) ) ;
258
254
}
@@ -262,7 +258,7 @@ impl<'a> Resolver<'a> {
262
258
let resolution =
263
259
self . resolution ( module, key) . try_borrow_mut ( ) . map_err ( |_| ( Determined , Weak :: No ) ) ?; // This happens when there is a cycle of imports.
264
260
265
- if let Some ( binding) = resolution. binding {
261
+ if let Some ( binding) = resolution. binding && let Some ( path_span ) = record_used {
266
262
if !restricted_shadowing && binding. expansion != LocalExpnId :: ROOT {
267
263
if let NameBindingKind :: Res ( _, true ) = binding. kind {
268
264
self . macro_expanded_macro_export_errors . insert ( ( path_span, binding. span ) ) ;
@@ -280,7 +276,7 @@ impl<'a> Resolver<'a> {
280
276
if usable { Ok ( binding) } else { Err ( ( Determined , Weak :: No ) ) }
281
277
} ;
282
278
283
- if record_used {
279
+ if let Some ( path_span ) = record_used {
284
280
return resolution
285
281
. binding
286
282
. and_then ( |binding| {
@@ -353,14 +349,8 @@ impl<'a> Resolver<'a> {
353
349
let ImportKind :: Single { source : ident, .. } = single_import. kind else {
354
350
unreachable ! ( ) ;
355
351
} ;
356
- match self . resolve_ident_in_module (
357
- module,
358
- ident,
359
- ns,
360
- & single_import. parent_scope ,
361
- false ,
362
- path_span,
363
- ) {
352
+ match self . resolve_ident_in_module ( module, ident, ns, & single_import. parent_scope , None )
353
+ {
364
354
Err ( Determined ) => continue ,
365
355
Ok ( binding)
366
356
if !self . is_accessible_from ( binding. vis , single_import. parent_scope . module ) =>
@@ -434,8 +424,7 @@ impl<'a> Resolver<'a> {
434
424
ident,
435
425
ns,
436
426
adjusted_parent_scope,
437
- false ,
438
- path_span,
427
+ None ,
439
428
) ;
440
429
441
430
match result {
@@ -783,13 +772,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
783
772
// For better failure detection, pretend that the import will
784
773
// not define any names while resolving its module path.
785
774
let orig_vis = import. vis . replace ( ty:: Visibility :: Invisible ) ;
786
- let path_res = self . r . resolve_path (
787
- & import. module_path ,
788
- None ,
789
- & import. parent_scope ,
790
- import. span ,
791
- CrateLint :: No ,
792
- ) ;
775
+ let path_res =
776
+ self . r . resolve_path ( & import. module_path , None , & import. parent_scope , CrateLint :: No ) ;
793
777
import. vis . set ( orig_vis) ;
794
778
795
779
match path_res {
@@ -828,8 +812,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
828
812
source,
829
813
ns,
830
814
& import. parent_scope ,
831
- false ,
832
- import. span ,
815
+ None ,
833
816
) ;
834
817
import. vis . set ( orig_vis) ;
835
818
source_bindings[ ns] . set ( binding) ;
@@ -882,15 +865,13 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
882
865
_ => None ,
883
866
} ;
884
867
let prev_ambiguity_errors_len = self . r . ambiguity_errors . len ( ) ;
885
- let crate_lint =
886
- CrateLint :: UsePath { root_id : import. root_id , root_span : import. root_span } ;
887
- let path_res = self . r . resolve_path (
888
- & import. module_path ,
889
- None ,
890
- & import. parent_scope ,
891
- import. span ,
892
- crate_lint,
893
- ) ;
868
+ let crate_lint = CrateLint :: UsePath {
869
+ root_id : import. root_id ,
870
+ root_span : import. root_span ,
871
+ path_span : import. span ,
872
+ } ;
873
+ let path_res =
874
+ self . r . resolve_path ( & import. module_path , None , & import. parent_scope , crate_lint) ;
894
875
let no_ambiguity = self . r . ambiguity_errors . len ( ) == prev_ambiguity_errors_len;
895
876
if let Some ( orig_unusable_binding) = orig_unusable_binding {
896
877
self . r . unusable_binding = orig_unusable_binding;
@@ -977,12 +958,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
977
958
// 2 segments, so the `resolve_path` above won't trigger it.
978
959
let mut full_path = import. module_path . clone ( ) ;
979
960
full_path. push ( Segment :: from_ident ( Ident :: empty ( ) ) ) ;
980
- self . r . lint_if_path_starts_with_module (
981
- crate_lint,
982
- & full_path,
983
- import. span ,
984
- None ,
985
- ) ;
961
+ self . r . lint_if_path_starts_with_module ( crate_lint, & full_path, None ) ;
986
962
}
987
963
988
964
if let ModuleOrUniformRoot :: Module ( module) = module {
@@ -1020,8 +996,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1020
996
ident,
1021
997
ns,
1022
998
& import. parent_scope ,
1023
- true ,
1024
- import. span ,
999
+ Some ( import. span ) ,
1025
1000
) ;
1026
1001
this. last_import_segment = orig_last_import_segment;
1027
1002
this. unusable_binding = orig_unusable_binding;
@@ -1082,8 +1057,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1082
1057
ident,
1083
1058
ns,
1084
1059
& import. parent_scope ,
1085
- true ,
1086
- import. span ,
1060
+ Some ( import. span ) ,
1087
1061
) ;
1088
1062
if binding. is_ok ( ) {
1089
1063
all_ns_failed = false ;
@@ -1249,12 +1223,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1249
1223
full_path. push ( Segment :: from_ident ( ident) ) ;
1250
1224
self . r . per_ns ( |this, ns| {
1251
1225
if let Ok ( binding) = source_bindings[ ns] . get ( ) {
1252
- this. lint_if_path_starts_with_module (
1253
- crate_lint,
1254
- & full_path,
1255
- import. span ,
1256
- Some ( binding) ,
1257
- ) ;
1226
+ this. lint_if_path_starts_with_module ( crate_lint, & full_path, Some ( binding) ) ;
1258
1227
}
1259
1228
} ) ;
1260
1229
}
@@ -1310,9 +1279,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1310
1279
target,
1311
1280
ScopeSet :: All ( ns, false ) ,
1312
1281
& import. parent_scope ,
1282
+ None ,
1313
1283
false ,
1314
- false ,
1315
- import. span ,
1316
1284
) {
1317
1285
Ok ( other_binding) => {
1318
1286
is_redundant[ ns] = Some (
0 commit comments