@@ -14,8 +14,8 @@ use crate::late::{
1414    ConstantHasGenerics ,  HasGenericParams ,  NoConstantGenericsReason ,  PathSource ,  Rib ,  RibKind , 
1515} ; 
1616use  crate :: macros:: { sub_namespace_match,  MacroRulesScope } ; 
17- use  crate :: BindingKey ; 
1817use  crate :: { errors,  AmbiguityError ,  AmbiguityErrorMisc ,  AmbiguityKind ,  Determinacy ,  Finalize } ; 
18+ use  crate :: { BindingKey ,  Used } ; 
1919use  crate :: { ImportKind ,  LexicalScopeBinding ,  Module ,  ModuleKind ,  ModuleOrUniformRoot } ; 
2020use  crate :: { NameBinding ,  NameBindingKind ,  ParentScope ,  PathResult ,  PrivacyError ,  Res } ; 
2121use  crate :: { ResolutionError ,  Resolver ,  Scope ,  ScopeSet ,  Segment ,  ToNameBinding ,  Weak } ; 
@@ -335,14 +335,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
335335                ModuleKind :: Block  => { }  // We can see through blocks 
336336                _ => break , 
337337            } 
338- 
339338            let  item = self . resolve_ident_in_module_unadjusted ( 
340339                ModuleOrUniformRoot :: Module ( module) , 
341340                ident, 
342341                ns, 
343342                parent_scope, 
344343                finalize, 
345344                ignore_binding, 
345+                 None , 
346346            ) ; 
347347            if  let  Ok ( binding)  = item { 
348348                // The ident resolves to an item. 
@@ -509,6 +509,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
509509                            !matches ! ( scope_set,  ScopeSet :: Late ( ..) ) , 
510510                            finalize, 
511511                            ignore_binding, 
512+                             Some ( Used :: Scope ) , 
512513                        ) ; 
513514                        match  binding { 
514515                            Ok ( binding)  => { 
@@ -579,6 +580,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
579580                                parent_scope, 
580581                                None , 
581582                                ignore_binding, 
583+                                 Some ( Used :: Other ) , 
582584                            )  { 
583585                                if  use_prelude || this. is_builtin_macro ( binding. res ( ) )  { 
584586                                    result = Ok ( ( binding,  Flags :: MISC_FROM_PRELUDE ) ) ; 
@@ -754,6 +756,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
754756            false , 
755757            finalize, 
756758            ignore_binding, 
759+             Some ( Used :: Other ) , 
757760        ) 
758761    } 
759762
@@ -766,6 +769,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
766769        parent_scope :  & ParentScope < ' a > , 
767770        finalize :  Option < Finalize > , 
768771        ignore_binding :  Option < NameBinding < ' a > > , 
772+         used :  Option < Used > , 
769773    )  -> Result < NameBinding < ' a > ,  Determinacy >  { 
770774        self . resolve_ident_in_module_unadjusted_ext ( 
771775            module, 
@@ -775,6 +779,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
775779            false , 
776780            finalize, 
777781            ignore_binding, 
782+             used, 
778783        ) 
779784        . map_err ( |( determinacy,  _) | determinacy) 
780785    } 
@@ -793,6 +798,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
793798        // This binding should be ignored during in-module resolution, so that we don't get 
794799        // "self-confirming" import resolutions during import validation and checking. 
795800        ignore_binding :  Option < NameBinding < ' a > > , 
801+         used :  Option < Used > , 
796802    )  -> Result < NameBinding < ' a > ,  ( Determinacy ,  Weak ) >  { 
797803        let  module = match  module { 
798804            ModuleOrUniformRoot :: Module ( module)  => module, 
@@ -849,15 +855,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
849855        let  key = BindingKey :: new ( ident,  ns) ; 
850856        let  resolution =
851857            self . resolution ( module,  key) . try_borrow_mut ( ) . map_err ( |_| ( Determined ,  Weak :: No ) ) ?;  // This happens when there is a cycle of imports. 
852- 
853858        // If the primary binding is unusable, search further and return the shadowed glob 
854859        // binding if it exists. What we really want here is having two separate scopes in 
855860        // a module - one for non-globs and one for globs, but until that's done use this 
856861        // hack to avoid inconsistent resolution ICEs during import validation. 
857862        let  binding = [ resolution. binding ,  resolution. shadowed_glob ] 
858863            . into_iter ( ) 
859864            . find_map ( |binding| if  binding == ignore_binding {  None  }  else  {  binding } ) ; 
860- 
861865        if  let  Some ( Finalize  {  path_span,  report_private,  .. } )  = finalize { 
862866            let  Some ( binding)  = binding else  { 
863867                return  Err ( ( Determined ,  Weak :: No ) ) ; 
@@ -901,8 +905,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
901905                    self . macro_expanded_macro_export_errors . insert ( ( path_span,  binding. span ) ) ; 
902906                } 
903907            } 
904- 
905-             self . record_use ( ident,  binding,  restricted_shadowing) ; 
908+             self . record_use ( ident,  binding,  used) ; 
906909            return  Ok ( binding) ; 
907910        } 
908911
@@ -923,6 +926,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
923926        // Check if one of single imports can still define the name, 
924927        // if it can then our result is not determined and can be invalidated. 
925928        for  single_import in  & resolution. single_imports  { 
929+             debug ! ( "single_import:{:?}" ,  single_import) ; 
926930            let  Some ( import_vis)  = single_import. vis . get ( )  else  { 
927931                continue ; 
928932            } ; 
@@ -1029,6 +1033,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
10291033                adjusted_parent_scope, 
10301034                None , 
10311035                ignore_binding, 
1036+                 Some ( Used :: Other ) , 
10321037            ) ; 
10331038
10341039            match  result { 
0 commit comments