@@ -175,8 +175,7 @@ impl<'a> Resolver<'a> {
175175 ident : Ident ,
176176 ns : Namespace ,
177177 parent_scope : & ParentScope < ' a > ,
178- record_used : bool ,
179- path_span : Span ,
178+ record_used : Option < Span > ,
180179 ) -> Result < & ' a NameBinding < ' a > , Determinacy > {
181180 self . resolve_ident_in_module_unadjusted_ext (
182181 module,
@@ -185,7 +184,6 @@ impl<'a> Resolver<'a> {
185184 parent_scope,
186185 false ,
187186 record_used,
188- path_span,
189187 )
190188 . map_err ( |( determinacy, _) | determinacy)
191189 }
@@ -199,8 +197,7 @@ impl<'a> Resolver<'a> {
199197 ns : Namespace ,
200198 parent_scope : & ParentScope < ' a > ,
201199 restricted_shadowing : bool ,
202- record_used : bool ,
203- path_span : Span ,
200+ record_used : Option < Span > ,
204201 ) -> Result < & ' a NameBinding < ' a > , ( Determinacy , Weak ) > {
205202 let module = match module {
206203 ModuleOrUniformRoot :: Module ( module) => module,
@@ -211,16 +208,16 @@ impl<'a> Resolver<'a> {
211208 ScopeSet :: AbsolutePath ( ns) ,
212209 parent_scope,
213210 record_used,
214- record_used,
215- path_span,
211+ record_used. is_some ( ) ,
216212 ) ;
217213 return binding. map_err ( |determinacy| ( determinacy, Weak :: No ) ) ;
218214 }
219215 ModuleOrUniformRoot :: ExternPrelude => {
220216 assert ! ( !restricted_shadowing) ;
221217 return if ns != TypeNS {
222218 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+ {
224221 Ok ( binding)
225222 } else if !self . graph_root . unexpanded_invocations . borrow ( ) . is_empty ( ) {
226223 // Macro-expanded `extern crate` items can add names to extern prelude.
@@ -251,8 +248,7 @@ impl<'a> Resolver<'a> {
251248 scopes,
252249 parent_scope,
253250 record_used,
254- record_used,
255- path_span,
251+ record_used. is_some ( ) ,
256252 ) ;
257253 return binding. map_err ( |determinacy| ( determinacy, Weak :: No ) ) ;
258254 }
@@ -262,7 +258,7 @@ impl<'a> Resolver<'a> {
262258 let resolution =
263259 self . resolution ( module, key) . try_borrow_mut ( ) . map_err ( |_| ( Determined , Weak :: No ) ) ?; // This happens when there is a cycle of imports.
264260
265- if let Some ( binding) = resolution. binding {
261+ if let Some ( binding) = resolution. binding && let Some ( path_span ) = record_used {
266262 if !restricted_shadowing && binding. expansion != LocalExpnId :: ROOT {
267263 if let NameBindingKind :: Res ( _, true ) = binding. kind {
268264 self . macro_expanded_macro_export_errors . insert ( ( path_span, binding. span ) ) ;
@@ -280,7 +276,7 @@ impl<'a> Resolver<'a> {
280276 if usable { Ok ( binding) } else { Err ( ( Determined , Weak :: No ) ) }
281277 } ;
282278
283- if record_used {
279+ if let Some ( path_span ) = record_used {
284280 return resolution
285281 . binding
286282 . and_then ( |binding| {
@@ -353,14 +349,8 @@ impl<'a> Resolver<'a> {
353349 let ImportKind :: Single { source : ident, .. } = single_import. kind else {
354350 unreachable ! ( ) ;
355351 } ;
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+ {
364354 Err ( Determined ) => continue ,
365355 Ok ( binding)
366356 if !self . is_accessible_from ( binding. vis , single_import. parent_scope . module ) =>
@@ -434,8 +424,7 @@ impl<'a> Resolver<'a> {
434424 ident,
435425 ns,
436426 adjusted_parent_scope,
437- false ,
438- path_span,
427+ None ,
439428 ) ;
440429
441430 match result {
@@ -783,13 +772,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
783772 // For better failure detection, pretend that the import will
784773 // not define any names while resolving its module path.
785774 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 ) ;
793777 import. vis . set ( orig_vis) ;
794778
795779 match path_res {
@@ -828,8 +812,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
828812 source,
829813 ns,
830814 & import. parent_scope ,
831- false ,
832- import. span ,
815+ None ,
833816 ) ;
834817 import. vis . set ( orig_vis) ;
835818 source_bindings[ ns] . set ( binding) ;
@@ -882,15 +865,13 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
882865 _ => None ,
883866 } ;
884867 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) ;
894875 let no_ambiguity = self . r . ambiguity_errors . len ( ) == prev_ambiguity_errors_len;
895876 if let Some ( orig_unusable_binding) = orig_unusable_binding {
896877 self . r . unusable_binding = orig_unusable_binding;
@@ -977,12 +958,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
977958 // 2 segments, so the `resolve_path` above won't trigger it.
978959 let mut full_path = import. module_path . clone ( ) ;
979960 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 ) ;
986962 }
987963
988964 if let ModuleOrUniformRoot :: Module ( module) = module {
@@ -1020,8 +996,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1020996 ident,
1021997 ns,
1022998 & import. parent_scope ,
1023- true ,
1024- import. span ,
999+ Some ( import. span ) ,
10251000 ) ;
10261001 this. last_import_segment = orig_last_import_segment;
10271002 this. unusable_binding = orig_unusable_binding;
@@ -1082,8 +1057,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
10821057 ident,
10831058 ns,
10841059 & import. parent_scope ,
1085- true ,
1086- import. span ,
1060+ Some ( import. span ) ,
10871061 ) ;
10881062 if binding. is_ok ( ) {
10891063 all_ns_failed = false ;
@@ -1249,12 +1223,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
12491223 full_path. push ( Segment :: from_ident ( ident) ) ;
12501224 self . r . per_ns ( |this, ns| {
12511225 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) ) ;
12581227 }
12591228 } ) ;
12601229 }
@@ -1310,9 +1279,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
13101279 target,
13111280 ScopeSet :: All ( ns, false ) ,
13121281 & import. parent_scope ,
1282+ None ,
13131283 false ,
1314- false ,
1315- import. span ,
13161284 ) {
13171285 Ok ( other_binding) => {
13181286 is_redundant[ ns] = Some (
0 commit comments