@@ -19,7 +19,7 @@ use crate::{
19
19
AmbiguityError , AmbiguityErrorMisc , AmbiguityKind , BindingKey , CmResolver , Determinacy ,
20
20
Finalize , ImportKind , LexicalScopeBinding , Module , ModuleKind , ModuleOrUniformRoot ,
21
21
NameBinding , NameBindingKind , ParentScope , PathResult , PrivacyError , Res , ResolutionError ,
22
- Resolver , Scope , ScopeSet , Segment , Used , Weak , errors,
22
+ Resolver , Scope , ScopeSet , Segment , Stage , Used , Weak , errors,
23
23
} ;
24
24
25
25
#[ derive( Copy , Clone ) ]
@@ -100,9 +100,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
100
100
101
101
let rust_2015 = ctxt. edition ( ) . is_rust_2015 ( ) ;
102
102
let ( ns, macro_kind) = match scope_set {
103
- ScopeSet :: All ( ns)
104
- | ScopeSet :: ModuleAndExternPrelude ( ns, _)
105
- | ScopeSet :: Late ( ns, ..) => ( ns, None ) ,
103
+ ScopeSet :: All ( ns) | ScopeSet :: ModuleAndExternPrelude ( ns, _) => ( ns, None ) ,
106
104
ScopeSet :: ExternPrelude => ( TypeNS , None ) ,
107
105
ScopeSet :: Macro ( macro_kind) => ( MacroNS , Some ( macro_kind) ) ,
108
106
} ;
@@ -347,11 +345,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
347
345
} else if let RibKind :: Module ( module) = rib. kind {
348
346
// Encountered a module item, abandon ribs and look into that module and preludes.
349
347
let parent_scope = & ParentScope { module, ..* parent_scope } ;
348
+ let finalize = finalize. map ( |f| Finalize { stage : Stage :: Late , ..f } ) ;
350
349
return self
351
350
. cm ( )
352
351
. resolve_ident_in_scope_set (
353
352
orig_ident,
354
- ScopeSet :: Late ( ns) ,
353
+ ScopeSet :: All ( ns) ,
355
354
parent_scope,
356
355
finalize,
357
356
finalize. is_some ( ) ,
@@ -405,9 +404,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
405
404
}
406
405
407
406
let ( ns, macro_kind) = match scope_set {
408
- ScopeSet :: All ( ns)
409
- | ScopeSet :: ModuleAndExternPrelude ( ns, _)
410
- | ScopeSet :: Late ( ns, ..) => ( ns, None ) ,
407
+ ScopeSet :: All ( ns) | ScopeSet :: ModuleAndExternPrelude ( ns, _) => ( ns, None ) ,
411
408
ScopeSet :: ExternPrelude => ( TypeNS , None ) ,
412
409
ScopeSet :: Macro ( macro_kind) => ( MacroNS , Some ( macro_kind) ) ,
413
410
} ;
@@ -431,8 +428,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
431
428
}
432
429
433
430
// Go through all the scopes and try to resolve the name.
434
- let derive_fallback_lint_id = match ( finalize, scope_set ) {
435
- ( Some ( finalize ) , ScopeSet :: Late ( .. ) ) => Some ( finalize . node_id ) ,
431
+ let derive_fallback_lint_id = match finalize {
432
+ Some ( Finalize { node_id , stage : Stage :: Late , .. } ) => Some ( node_id) ,
436
433
_ => None ,
437
434
} ;
438
435
let break_result = self . visit_scopes (
@@ -509,11 +506,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
509
506
ident,
510
507
ns,
511
508
adjusted_parent_scope,
512
- if matches ! ( scope_set, ScopeSet :: Late ( ..) ) {
513
- Shadowing :: Unrestricted
514
- } else {
515
- Shadowing :: Restricted
516
- } ,
509
+ Shadowing :: Restricted ,
517
510
adjusted_finalize,
518
511
ignore_binding,
519
512
ignore_import,
@@ -642,7 +635,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
642
635
return None ;
643
636
}
644
637
645
- if finalize . is_none ( ) || matches ! ( scope_set , ScopeSet :: Late ( .. ) ) {
638
+ if matches ! ( finalize , None | Some ( Finalize { stage : Stage :: Late , .. } ) ) {
646
639
return Some ( Ok ( binding) ) ;
647
640
}
648
641
@@ -1039,6 +1032,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1039
1032
// Forbid expanded shadowing to avoid time travel.
1040
1033
if let Some ( shadowed_glob) = shadowed_glob
1041
1034
&& shadowing == Shadowing :: Restricted
1035
+ && finalize. stage == Stage :: Early
1042
1036
&& binding. expansion != LocalExpnId :: ROOT
1043
1037
&& binding. res ( ) != shadowed_glob. res ( )
1044
1038
{
0 commit comments