@@ -311,13 +311,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
311
311
312
312
// Walk backwards up the ribs in scope.
313
313
let mut module = self . graph_root ;
314
- for i in ( 0 .. ribs. len ( ) ) . rev ( ) {
315
- debug ! ( "walk rib\n {:?}" , ribs [ i ] . bindings) ;
314
+ for ( i , rib ) in ribs. iter ( ) . enumerate ( ) . rev ( ) {
315
+ debug ! ( "walk rib\n {:?}" , rib . bindings) ;
316
316
// Use the rib kind to determine whether we are resolving parameters
317
317
// (macro 2.0 hygiene) or local variables (`macro_rules` hygiene).
318
- let rib_ident = if ribs[ i] . kind . contains_params ( ) { normalized_ident } else { ident } ;
319
- if let Some ( ( original_rib_ident_def, res) ) = ribs[ i] . bindings . get_key_value ( & rib_ident)
320
- {
318
+ let rib_ident = if rib. kind . contains_params ( ) { normalized_ident } else { ident } ;
319
+ if let Some ( ( original_rib_ident_def, res) ) = rib. bindings . get_key_value ( & rib_ident) {
321
320
// The ident resolves to a type parameter or local variable.
322
321
return Some ( LexicalScopeBinding :: Res ( self . validate_res_from_ribs (
323
322
i,
@@ -329,7 +328,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
329
328
) ) ) ;
330
329
}
331
330
332
- module = match ribs [ i ] . kind {
331
+ module = match rib . kind {
333
332
RibKind :: Module ( module) => module,
334
333
RibKind :: MacroDefinition ( def) if def == self . macro_def ( ident. span . ctxt ( ) ) => {
335
334
// If an invocation of this macro created `ident`, give up on `ident`
@@ -350,6 +349,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
350
349
ident,
351
350
ns,
352
351
parent_scope,
352
+ false ,
353
353
finalize. map ( |finalize| Finalize { used : Used :: Scope , ..finalize } ) ,
354
354
ignore_binding,
355
355
None ,
@@ -494,7 +494,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
494
494
Scope :: CrateRoot => {
495
495
let root_ident = Ident :: new ( kw:: PathRoot , ident. span ) ;
496
496
let root_module = this. resolve_crate_root ( root_ident) ;
497
- let binding = this. resolve_ident_in_module_ext (
497
+ let binding = this. resolve_ident_in_module (
498
498
ModuleOrUniformRoot :: Module ( root_module) ,
499
499
ident,
500
500
ns,
@@ -516,7 +516,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
516
516
}
517
517
Scope :: Module ( module, derive_fallback_lint_id) => {
518
518
let adjusted_parent_scope = & ParentScope { module, ..* parent_scope } ;
519
- let binding = this. resolve_ident_in_module_unadjusted_ext (
519
+ let binding = this. resolve_ident_in_module_unadjusted (
520
520
ModuleOrUniformRoot :: Module ( module) ,
521
521
ident,
522
522
ns,
@@ -590,6 +590,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
590
590
ident,
591
591
ns,
592
592
parent_scope,
593
+ false ,
593
594
None ,
594
595
ignore_binding,
595
596
ignore_import,
@@ -748,35 +749,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
748
749
parent_scope : & ParentScope < ' ra > ,
749
750
ignore_import : Option < Import < ' ra > > ,
750
751
) -> Result < NameBinding < ' ra > , Determinacy > {
751
- self . resolve_ident_in_module_ext ( module, ident, ns, parent_scope, None , None , ignore_import)
752
+ self . resolve_ident_in_module ( module, ident, ns, parent_scope, None , None , ignore_import)
752
753
. map_err ( |( determinacy, _) | determinacy)
753
754
}
754
755
755
756
#[ instrument( level = "debug" , skip( self ) ) ]
756
757
pub ( crate ) fn resolve_ident_in_module (
757
- & mut self ,
758
- module : ModuleOrUniformRoot < ' ra > ,
759
- ident : Ident ,
760
- ns : Namespace ,
761
- parent_scope : & ParentScope < ' ra > ,
762
- finalize : Option < Finalize > ,
763
- ignore_binding : Option < NameBinding < ' ra > > ,
764
- ignore_import : Option < Import < ' ra > > ,
765
- ) -> Result < NameBinding < ' ra > , Determinacy > {
766
- self . resolve_ident_in_module_ext (
767
- module,
768
- ident,
769
- ns,
770
- parent_scope,
771
- finalize,
772
- ignore_binding,
773
- ignore_import,
774
- )
775
- . map_err ( |( determinacy, _) | determinacy)
776
- }
777
-
778
- #[ instrument( level = "debug" , skip( self ) ) ]
779
- fn resolve_ident_in_module_ext (
780
758
& mut self ,
781
759
module : ModuleOrUniformRoot < ' ra > ,
782
760
mut ident : Ident ,
@@ -803,7 +781,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
803
781
// No adjustments
804
782
}
805
783
}
806
- self . resolve_ident_in_module_unadjusted_ext (
784
+ self . resolve_ident_in_module_unadjusted (
807
785
module,
808
786
ident,
809
787
ns,
@@ -815,34 +793,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
815
793
)
816
794
}
817
795
818
- #[ instrument( level = "debug" , skip( self ) ) ]
819
- fn resolve_ident_in_module_unadjusted (
820
- & mut self ,
821
- module : ModuleOrUniformRoot < ' ra > ,
822
- ident : Ident ,
823
- ns : Namespace ,
824
- parent_scope : & ParentScope < ' ra > ,
825
- finalize : Option < Finalize > ,
826
- ignore_binding : Option < NameBinding < ' ra > > ,
827
- ignore_import : Option < Import < ' ra > > ,
828
- ) -> Result < NameBinding < ' ra > , Determinacy > {
829
- self . resolve_ident_in_module_unadjusted_ext (
830
- module,
831
- ident,
832
- ns,
833
- parent_scope,
834
- false ,
835
- finalize,
836
- ignore_binding,
837
- ignore_import,
838
- )
839
- . map_err ( |( determinacy, _) | determinacy)
840
- }
841
-
842
796
/// Attempts to resolve `ident` in namespaces `ns` of `module`.
843
797
/// Invariant: if `finalize` is `Some`, expansion and import resolution must be complete.
844
798
#[ instrument( level = "debug" , skip( self ) ) ]
845
- fn resolve_ident_in_module_unadjusted_ext (
799
+ fn resolve_ident_in_module_unadjusted (
846
800
& mut self ,
847
801
module : ModuleOrUniformRoot < ' ra > ,
848
802
ident : Ident ,
@@ -1047,13 +1001,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1047
1001
ignore_binding,
1048
1002
ignore_import,
1049
1003
) {
1050
- Err ( Determined ) => continue ,
1004
+ Err ( ( Determined , _ ) ) => continue ,
1051
1005
Ok ( binding)
1052
1006
if !self . is_accessible_from ( binding. vis , single_import. parent_scope . module ) =>
1053
1007
{
1054
1008
continue ;
1055
1009
}
1056
- Ok ( _) | Err ( Undetermined ) => return Err ( ( Undetermined , Weak :: No ) ) ,
1010
+ Ok ( _) | Err ( ( Undetermined , _ ) ) => return Err ( ( Undetermined , Weak :: No ) ) ,
1057
1011
}
1058
1012
}
1059
1013
@@ -1122,19 +1076,20 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1122
1076
ident,
1123
1077
ns,
1124
1078
adjusted_parent_scope,
1079
+ false ,
1125
1080
None ,
1126
1081
ignore_binding,
1127
1082
ignore_import,
1128
1083
) ;
1129
1084
1130
1085
match result {
1131
- Err ( Determined ) => continue ,
1086
+ Err ( ( Determined , _ ) ) => continue ,
1132
1087
Ok ( binding)
1133
1088
if !self . is_accessible_from ( binding. vis , glob_import. parent_scope . module ) =>
1134
1089
{
1135
1090
continue ;
1136
1091
}
1137
- Ok ( _) | Err ( Undetermined ) => return Err ( ( Undetermined , Weak :: Yes ) ) ,
1092
+ Ok ( _) | Err ( ( Undetermined , _ ) ) => return Err ( ( Undetermined , Weak :: Yes ) ) ,
1138
1093
}
1139
1094
}
1140
1095
@@ -1200,7 +1155,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1200
1155
// Still doesn't deal with upvars
1201
1156
if let Some ( span) = finalize {
1202
1157
let ( span, resolution_error) = match item {
1203
- None if rib_ident. as_str ( ) == "self" => ( span, LowercaseSelf ) ,
1158
+ None if rib_ident. name == kw:: SelfLower => {
1159
+ ( span, LowercaseSelf )
1160
+ }
1204
1161
None => {
1205
1162
// If we have a `let name = expr;`, we have the span for
1206
1163
// `name` and use that to see if it is followed by a type
@@ -1563,6 +1520,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1563
1520
ignore_binding,
1564
1521
ignore_import,
1565
1522
)
1523
+ . map_err ( |( determinacy, _) | determinacy)
1566
1524
} else if let Some ( ribs) = ribs
1567
1525
&& let Some ( TypeNS | ValueNS ) = opt_ns
1568
1526
{
0 commit comments