@@ -311,13 +311,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
311311
312312 // Walk backwards up the ribs in scope.
313313 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) ;
316316 // Use the rib kind to determine whether we are resolving parameters
317317 // (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) {
321320 // The ident resolves to a type parameter or local variable.
322321 return Some ( LexicalScopeBinding :: Res ( self . validate_res_from_ribs (
323322 i,
@@ -329,7 +328,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
329328 ) ) ) ;
330329 }
331330
332- module = match ribs [ i ] . kind {
331+ module = match rib . kind {
333332 RibKind :: Module ( module) => module,
334333 RibKind :: MacroDefinition ( def) if def == self . macro_def ( ident. span . ctxt ( ) ) => {
335334 // If an invocation of this macro created `ident`, give up on `ident`
@@ -350,6 +349,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
350349 ident,
351350 ns,
352351 parent_scope,
352+ false ,
353353 finalize. map ( |finalize| Finalize { used : Used :: Scope , ..finalize } ) ,
354354 ignore_binding,
355355 None ,
@@ -494,7 +494,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
494494 Scope :: CrateRoot => {
495495 let root_ident = Ident :: new ( kw:: PathRoot , ident. span ) ;
496496 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 (
498498 ModuleOrUniformRoot :: Module ( root_module) ,
499499 ident,
500500 ns,
@@ -516,7 +516,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
516516 }
517517 Scope :: Module ( module, derive_fallback_lint_id) => {
518518 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 (
520520 ModuleOrUniformRoot :: Module ( module) ,
521521 ident,
522522 ns,
@@ -590,6 +590,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
590590 ident,
591591 ns,
592592 parent_scope,
593+ false ,
593594 None ,
594595 ignore_binding,
595596 ignore_import,
@@ -748,35 +749,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
748749 parent_scope : & ParentScope < ' ra > ,
749750 ignore_import : Option < Import < ' ra > > ,
750751 ) -> 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)
752753 . map_err ( |( determinacy, _) | determinacy)
753754 }
754755
755756 #[ instrument( level = "debug" , skip( self ) ) ]
756757 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 (
780758 & mut self ,
781759 module : ModuleOrUniformRoot < ' ra > ,
782760 mut ident : Ident ,
@@ -803,7 +781,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
803781 // No adjustments
804782 }
805783 }
806- self . resolve_ident_in_module_unadjusted_ext (
784+ self . resolve_ident_in_module_unadjusted (
807785 module,
808786 ident,
809787 ns,
@@ -815,34 +793,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
815793 )
816794 }
817795
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-
842796 /// Attempts to resolve `ident` in namespaces `ns` of `module`.
843797 /// Invariant: if `finalize` is `Some`, expansion and import resolution must be complete.
844798 #[ instrument( level = "debug" , skip( self ) ) ]
845- fn resolve_ident_in_module_unadjusted_ext (
799+ fn resolve_ident_in_module_unadjusted (
846800 & mut self ,
847801 module : ModuleOrUniformRoot < ' ra > ,
848802 ident : Ident ,
@@ -1047,13 +1001,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10471001 ignore_binding,
10481002 ignore_import,
10491003 ) {
1050- Err ( Determined ) => continue ,
1004+ Err ( ( Determined , _ ) ) => continue ,
10511005 Ok ( binding)
10521006 if !self . is_accessible_from ( binding. vis , single_import. parent_scope . module ) =>
10531007 {
10541008 continue ;
10551009 }
1056- Ok ( _) | Err ( Undetermined ) => return Err ( ( Undetermined , Weak :: No ) ) ,
1010+ Ok ( _) | Err ( ( Undetermined , _ ) ) => return Err ( ( Undetermined , Weak :: No ) ) ,
10571011 }
10581012 }
10591013
@@ -1122,19 +1076,20 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11221076 ident,
11231077 ns,
11241078 adjusted_parent_scope,
1079+ false ,
11251080 None ,
11261081 ignore_binding,
11271082 ignore_import,
11281083 ) ;
11291084
11301085 match result {
1131- Err ( Determined ) => continue ,
1086+ Err ( ( Determined , _ ) ) => continue ,
11321087 Ok ( binding)
11331088 if !self . is_accessible_from ( binding. vis , glob_import. parent_scope . module ) =>
11341089 {
11351090 continue ;
11361091 }
1137- Ok ( _) | Err ( Undetermined ) => return Err ( ( Undetermined , Weak :: Yes ) ) ,
1092+ Ok ( _) | Err ( ( Undetermined , _ ) ) => return Err ( ( Undetermined , Weak :: Yes ) ) ,
11381093 }
11391094 }
11401095
@@ -1200,7 +1155,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
12001155 // Still doesn't deal with upvars
12011156 if let Some ( span) = finalize {
12021157 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+ }
12041161 None => {
12051162 // If we have a `let name = expr;`, we have the span for
12061163 // `name` and use that to see if it is followed by a type
@@ -1563,6 +1520,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15631520 ignore_binding,
15641521 ignore_import,
15651522 )
1523+ . map_err ( |( determinacy, _) | determinacy)
15661524 } else if let Some ( ribs) = ribs
15671525 && let Some ( TypeNS | ValueNS ) = opt_ns
15681526 {
0 commit comments