@@ -748,35 +748,31 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
748748 fn visit_foreign_item ( & mut self , foreign_item : & ' ast ForeignItem ) {
749749 match foreign_item. kind {
750750 ForeignItemKind :: TyAlias ( box TyAlias { ref generics, .. } ) => {
751- self . with_lifetime_rib ( LifetimeRibKind :: Item , |this| {
752- this. with_generic_param_rib (
753- & generics. params ,
754- ItemRibKind ( HasGenericParams :: Yes ( generics. span ) ) ,
755- LifetimeRibKind :: Generics {
756- binder : foreign_item. id ,
757- kind : LifetimeBinderKind :: Item ,
758- span : generics. span ,
759- } ,
760- |this| visit:: walk_foreign_item ( this, foreign_item) ,
761- )
762- } ) ;
751+ self . with_generic_param_rib (
752+ & generics. params ,
753+ ItemRibKind ( HasGenericParams :: Yes ( generics. span ) ) ,
754+ LifetimeRibKind :: Generics {
755+ binder : foreign_item. id ,
756+ kind : LifetimeBinderKind :: Item ,
757+ span : generics. span ,
758+ } ,
759+ |this| visit:: walk_foreign_item ( this, foreign_item) ,
760+ ) ;
763761 }
764762 ForeignItemKind :: Fn ( box Fn { ref generics, .. } ) => {
765- self . with_lifetime_rib ( LifetimeRibKind :: Item , |this| {
766- this. with_generic_param_rib (
767- & generics. params ,
768- ItemRibKind ( HasGenericParams :: Yes ( generics. span ) ) ,
769- LifetimeRibKind :: Generics {
770- binder : foreign_item. id ,
771- kind : LifetimeBinderKind :: Function ,
772- span : generics. span ,
773- } ,
774- |this| visit:: walk_foreign_item ( this, foreign_item) ,
775- )
776- } ) ;
763+ self . with_generic_param_rib (
764+ & generics. params ,
765+ ItemRibKind ( HasGenericParams :: Yes ( generics. span ) ) ,
766+ LifetimeRibKind :: Generics {
767+ binder : foreign_item. id ,
768+ kind : LifetimeBinderKind :: Function ,
769+ span : generics. span ,
770+ } ,
771+ |this| visit:: walk_foreign_item ( this, foreign_item) ,
772+ ) ;
777773 }
778774 ForeignItemKind :: Static ( ..) => {
779- self . with_item_rib ( |this| {
775+ self . with_static_rib ( |this| {
780776 visit:: walk_foreign_item ( this, foreign_item) ;
781777 } ) ;
782778 }
@@ -1391,9 +1387,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13911387 return self . resolve_anonymous_lifetime ( lifetime, false ) ;
13921388 }
13931389
1394- let mut indices = ( 0 ..self . lifetime_ribs . len ( ) ) . rev ( ) ;
1395- for i in & mut indices {
1396- let rib = & self . lifetime_ribs [ i] ;
1390+ let mut lifetime_rib_iter = self . lifetime_ribs . iter ( ) . rev ( ) ;
1391+ while let Some ( rib) = lifetime_rib_iter. next ( ) {
13971392 let normalized_ident = ident. normalize_to_macros_2_0 ( ) ;
13981393 if let Some ( & ( _, res) ) = rib. bindings . get ( & normalized_ident) {
13991394 self . record_lifetime_res ( lifetime. id , res, LifetimeElisionCandidate :: Named ) ;
@@ -1470,8 +1465,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
14701465 }
14711466
14721467 let mut outer_res = None ;
1473- for i in indices {
1474- let rib = & self . lifetime_ribs [ i] ;
1468+ for rib in lifetime_rib_iter {
14751469 let normalized_ident = ident. normalize_to_macros_2_0 ( ) ;
14761470 if let Some ( ( & outer, _) ) = rib. bindings . get_key_value ( & normalized_ident) {
14771471 outer_res = Some ( outer) ;
@@ -1498,8 +1492,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
14981492 count : 1 ,
14991493 } ;
15001494 let elision_candidate = LifetimeElisionCandidate :: Missing ( missing_lifetime) ;
1501- for i in ( 0 ..self . lifetime_ribs . len ( ) ) . rev ( ) {
1502- let rib = & mut self . lifetime_ribs [ i] ;
1495+ for rib in self . lifetime_ribs . iter ( ) . rev ( ) {
15031496 debug ! ( ?rib. kind) ;
15041497 match rib. kind {
15051498 LifetimeRibKind :: AnonymousCreateParameter { binder, .. } => {
@@ -2213,7 +2206,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
22132206 }
22142207
22152208 ItemKind :: Static ( ref ty, _, ref expr) | ItemKind :: Const ( _, ref ty, ref expr) => {
2216- self . with_item_rib ( |this| {
2209+ self . with_static_rib ( |this| {
22172210 this. with_lifetime_rib ( LifetimeRibKind :: Elided ( LifetimeRes :: Static ) , |this| {
22182211 this. visit_ty ( ty) ;
22192212 } ) ;
@@ -2408,11 +2401,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
24082401 self . label_ribs . pop ( ) ;
24092402 }
24102403
2411- fn with_item_rib ( & mut self , f : impl FnOnce ( & mut Self ) ) {
2404+ fn with_static_rib ( & mut self , f : impl FnOnce ( & mut Self ) ) {
24122405 let kind = ItemRibKind ( HasGenericParams :: No ) ;
2413- self . with_lifetime_rib ( LifetimeRibKind :: Item , |this| {
2414- this. with_rib ( ValueNS , kind, |this| this. with_rib ( TypeNS , kind, f) )
2415- } )
2406+ self . with_rib ( ValueNS , kind, |this| this. with_rib ( TypeNS , kind, f) )
24162407 }
24172408
24182409 // HACK(min_const_generics,const_evaluatable_unchecked): We
0 commit comments