@@ -14,8 +14,8 @@ use crate::late::{
14
14
ConstantHasGenerics , HasGenericParams , NoConstantGenericsReason , PathSource , Rib , RibKind ,
15
15
} ;
16
16
use crate :: macros:: { sub_namespace_match, MacroRulesScope } ;
17
- use crate :: BindingKey ;
18
17
use crate :: { errors, AmbiguityError , AmbiguityErrorMisc , AmbiguityKind , Determinacy , Finalize } ;
18
+ use crate :: { BindingKey , Used } ;
19
19
use crate :: { ImportKind , LexicalScopeBinding , Module , ModuleKind , ModuleOrUniformRoot } ;
20
20
use crate :: { NameBinding , NameBindingKind , ParentScope , PathResult , PrivacyError , Res } ;
21
21
use crate :: { ResolutionError , Resolver , Scope , ScopeSet , Segment , ToNameBinding , Weak } ;
@@ -335,14 +335,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
335
335
ModuleKind :: Block => { } // We can see through blocks
336
336
_ => break ,
337
337
}
338
-
339
338
let item = self . resolve_ident_in_module_unadjusted (
340
339
ModuleOrUniformRoot :: Module ( module) ,
341
340
ident,
342
341
ns,
343
342
parent_scope,
344
343
finalize,
345
344
ignore_binding,
345
+ None ,
346
346
) ;
347
347
if let Ok ( binding) = item {
348
348
// The ident resolves to an item.
@@ -509,6 +509,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
509
509
!matches ! ( scope_set, ScopeSet :: Late ( ..) ) ,
510
510
finalize,
511
511
ignore_binding,
512
+ Some ( Used :: Scope ) ,
512
513
) ;
513
514
match binding {
514
515
Ok ( binding) => {
@@ -579,6 +580,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
579
580
parent_scope,
580
581
None ,
581
582
ignore_binding,
583
+ Some ( Used :: Other ) ,
582
584
) {
583
585
if use_prelude || this. is_builtin_macro ( binding. res ( ) ) {
584
586
result = Ok ( ( binding, Flags :: MISC_FROM_PRELUDE ) ) ;
@@ -754,6 +756,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
754
756
false ,
755
757
finalize,
756
758
ignore_binding,
759
+ Some ( Used :: Other ) ,
757
760
)
758
761
}
759
762
@@ -766,6 +769,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
766
769
parent_scope : & ParentScope < ' a > ,
767
770
finalize : Option < Finalize > ,
768
771
ignore_binding : Option < NameBinding < ' a > > ,
772
+ used : Option < Used > ,
769
773
) -> Result < NameBinding < ' a > , Determinacy > {
770
774
self . resolve_ident_in_module_unadjusted_ext (
771
775
module,
@@ -775,6 +779,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
775
779
false ,
776
780
finalize,
777
781
ignore_binding,
782
+ used,
778
783
)
779
784
. map_err ( |( determinacy, _) | determinacy)
780
785
}
@@ -793,6 +798,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
793
798
// This binding should be ignored during in-module resolution, so that we don't get
794
799
// "self-confirming" import resolutions during import validation and checking.
795
800
ignore_binding : Option < NameBinding < ' a > > ,
801
+ used : Option < Used > ,
796
802
) -> Result < NameBinding < ' a > , ( Determinacy , Weak ) > {
797
803
let module = match module {
798
804
ModuleOrUniformRoot :: Module ( module) => module,
@@ -849,15 +855,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
849
855
let key = BindingKey :: new ( ident, ns) ;
850
856
let resolution =
851
857
self . resolution ( module, key) . try_borrow_mut ( ) . map_err ( |_| ( Determined , Weak :: No ) ) ?; // This happens when there is a cycle of imports.
852
-
853
858
// If the primary binding is unusable, search further and return the shadowed glob
854
859
// binding if it exists. What we really want here is having two separate scopes in
855
860
// a module - one for non-globs and one for globs, but until that's done use this
856
861
// hack to avoid inconsistent resolution ICEs during import validation.
857
862
let binding = [ resolution. binding , resolution. shadowed_glob ]
858
863
. into_iter ( )
859
864
. find_map ( |binding| if binding == ignore_binding { None } else { binding } ) ;
860
-
861
865
if let Some ( Finalize { path_span, report_private, .. } ) = finalize {
862
866
let Some ( binding) = binding else {
863
867
return Err ( ( Determined , Weak :: No ) ) ;
@@ -901,8 +905,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
901
905
self . macro_expanded_macro_export_errors . insert ( ( path_span, binding. span ) ) ;
902
906
}
903
907
}
904
-
905
- self . record_use ( ident, binding, restricted_shadowing) ;
908
+ self . record_use ( ident, binding, used) ;
906
909
return Ok ( binding) ;
907
910
}
908
911
@@ -923,6 +926,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
923
926
// Check if one of single imports can still define the name,
924
927
// if it can then our result is not determined and can be invalidated.
925
928
for single_import in & resolution. single_imports {
929
+ debug ! ( "single_import:{:?}" , single_import) ;
926
930
let Some ( import_vis) = single_import. vis . get ( ) else {
927
931
continue ;
928
932
} ;
@@ -1029,6 +1033,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1029
1033
adjusted_parent_scope,
1030
1034
None ,
1031
1035
ignore_binding,
1036
+ Some ( Used :: Other ) ,
1032
1037
) ;
1033
1038
1034
1039
match result {
0 commit comments