@@ -748,35 +748,31 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
748
748
fn visit_foreign_item ( & mut self , foreign_item : & ' ast ForeignItem ) {
749
749
match foreign_item. kind {
750
750
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
+ ) ;
763
761
}
764
762
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
+ ) ;
777
773
}
778
774
ForeignItemKind :: Static ( ..) => {
779
- self . with_item_rib ( |this| {
775
+ self . with_static_rib ( |this| {
780
776
visit:: walk_foreign_item ( this, foreign_item) ;
781
777
} ) ;
782
778
}
@@ -1391,9 +1387,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1391
1387
return self . resolve_anonymous_lifetime ( lifetime, false ) ;
1392
1388
}
1393
1389
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 ( ) {
1397
1392
let normalized_ident = ident. normalize_to_macros_2_0 ( ) ;
1398
1393
if let Some ( & ( _, res) ) = rib. bindings . get ( & normalized_ident) {
1399
1394
self . record_lifetime_res ( lifetime. id , res, LifetimeElisionCandidate :: Named ) ;
@@ -1470,8 +1465,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1470
1465
}
1471
1466
1472
1467
let mut outer_res = None ;
1473
- for i in indices {
1474
- let rib = & self . lifetime_ribs [ i] ;
1468
+ for rib in lifetime_rib_iter {
1475
1469
let normalized_ident = ident. normalize_to_macros_2_0 ( ) ;
1476
1470
if let Some ( ( & outer, _) ) = rib. bindings . get_key_value ( & normalized_ident) {
1477
1471
outer_res = Some ( outer) ;
@@ -1498,8 +1492,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1498
1492
count : 1 ,
1499
1493
} ;
1500
1494
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 ( ) {
1503
1496
debug ! ( ?rib. kind) ;
1504
1497
match rib. kind {
1505
1498
LifetimeRibKind :: AnonymousCreateParameter { binder, .. } => {
@@ -2213,7 +2206,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2213
2206
}
2214
2207
2215
2208
ItemKind :: Static ( ref ty, _, ref expr) | ItemKind :: Const ( _, ref ty, ref expr) => {
2216
- self . with_item_rib ( |this| {
2209
+ self . with_static_rib ( |this| {
2217
2210
this. with_lifetime_rib ( LifetimeRibKind :: Elided ( LifetimeRes :: Static ) , |this| {
2218
2211
this. visit_ty ( ty) ;
2219
2212
} ) ;
@@ -2408,11 +2401,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2408
2401
self . label_ribs . pop ( ) ;
2409
2402
}
2410
2403
2411
- fn with_item_rib ( & mut self , f : impl FnOnce ( & mut Self ) ) {
2404
+ fn with_static_rib ( & mut self , f : impl FnOnce ( & mut Self ) ) {
2412
2405
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) )
2416
2407
}
2417
2408
2418
2409
// HACK(min_const_generics,const_evaluatable_unchecked): We
0 commit comments