@@ -262,9 +262,6 @@ enum LifetimeRibKind {
262
262
/// error on default object bounds (e.g., `Box<dyn Foo>`).
263
263
AnonymousReportError ,
264
264
265
- /// Pass responsibility to `resolve_lifetime` code for all cases.
266
- AnonymousPassThrough ( NodeId ) ,
267
-
268
265
/// Replace all anonymous lifetimes by provided lifetime.
269
266
Elided ( LifetimeRes ) ,
270
267
@@ -868,7 +865,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
868
865
let previous_state = replace ( & mut this. in_func_body , true ) ;
869
866
// Resolve the function body, potentially inside the body of an async closure
870
867
this. with_lifetime_rib (
871
- LifetimeRibKind :: AnonymousPassThrough ( fn_id) ,
868
+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : fn_id } ) ,
872
869
|this| this. visit_block ( body) ,
873
870
) ;
874
871
@@ -896,7 +893,9 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
896
893
this. with_lifetime_rib (
897
894
match binder {
898
895
ClosureBinder :: NotPresent => {
899
- LifetimeRibKind :: AnonymousPassThrough ( fn_id)
896
+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous {
897
+ binder : fn_id,
898
+ } )
900
899
}
901
900
ClosureBinder :: For { .. } => LifetimeRibKind :: AnonymousReportError ,
902
901
} ,
@@ -908,7 +907,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
908
907
let previous_state = replace ( & mut this. in_func_body , true ) ;
909
908
// Resolve the function body, potentially inside the body of an async closure
910
909
this. with_lifetime_rib (
911
- LifetimeRibKind :: AnonymousPassThrough ( fn_id) ,
910
+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : fn_id } ) ,
912
911
|this| this. visit_expr ( body) ,
913
912
) ;
914
913
@@ -1053,8 +1052,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
1053
1052
visit:: walk_generic_args ( self , path_span, args) ;
1054
1053
break ;
1055
1054
}
1056
- LifetimeRibKind :: AnonymousPassThrough ( ..)
1057
- | LifetimeRibKind :: AnonymousCreateParameter { .. }
1055
+ LifetimeRibKind :: AnonymousCreateParameter { .. }
1058
1056
| LifetimeRibKind :: AnonymousReportError
1059
1057
| LifetimeRibKind :: Elided ( _)
1060
1058
| LifetimeRibKind :: ElisionFailure
@@ -1415,8 +1413,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1415
1413
| LifetimeRibKind :: AnonymousReportError
1416
1414
| LifetimeRibKind :: ElisionFailure => Some ( LifetimeUseSet :: Many ) ,
1417
1415
// An anonymous lifetime is legal here, go ahead.
1418
- LifetimeRibKind :: AnonymousPassThrough ( _)
1419
- | LifetimeRibKind :: AnonymousCreateParameter { .. } => {
1416
+ LifetimeRibKind :: AnonymousCreateParameter { .. } => {
1420
1417
Some ( LifetimeUseSet :: One { use_span : ident. span , use_ctxt } )
1421
1418
}
1422
1419
// Only report if eliding the lifetime would have the same
@@ -1527,14 +1524,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1527
1524
self . record_lifetime_res ( lifetime. id , LifetimeRes :: Error , elision_candidate) ;
1528
1525
return ;
1529
1526
}
1530
- LifetimeRibKind :: AnonymousPassThrough ( node_id) => {
1531
- self . record_lifetime_res (
1532
- lifetime. id ,
1533
- LifetimeRes :: Anonymous { binder : node_id, elided } ,
1534
- elision_candidate,
1535
- ) ;
1536
- return ;
1537
- }
1538
1527
LifetimeRibKind :: Elided ( res) => {
1539
1528
self . record_lifetime_res ( lifetime. id , res, elision_candidate) ;
1540
1529
return ;
@@ -1658,8 +1647,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1658
1647
// Do not create a parameter for patterns and expressions.
1659
1648
for rib in self . lifetime_ribs . iter ( ) . rev ( ) {
1660
1649
match rib. kind {
1661
- LifetimeRibKind :: AnonymousPassThrough ( binder) => {
1662
- let res = LifetimeRes :: Anonymous { binder, elided : true } ;
1650
+ LifetimeRibKind :: Elided ( res @ LifetimeRes :: Anonymous { .. } ) => {
1663
1651
for id in node_ids {
1664
1652
self . record_lifetime_res ( id, res, LifetimeElisionCandidate :: Named ) ;
1665
1653
}
@@ -1673,8 +1661,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1673
1661
// FIXME(cjgillot) This resolution is wrong, but this does not matter
1674
1662
// since these cases are erroneous anyway. Lifetime resolution should
1675
1663
// emit a "missing lifetime specifier" diagnostic.
1676
- let res =
1677
- LifetimeRes :: Anonymous { binder : DUMMY_NODE_ID , elided : true } ;
1664
+ let res = LifetimeRes :: Anonymous { binder : DUMMY_NODE_ID } ;
1678
1665
for id in node_ids {
1679
1666
self . record_lifetime_res ( id, res, LifetimeElisionCandidate :: Named ) ;
1680
1667
}
@@ -1753,19 +1740,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1753
1740
}
1754
1741
break ;
1755
1742
}
1756
- // `PassThrough` is the normal case.
1757
- LifetimeRibKind :: AnonymousPassThrough ( binder) => {
1758
- let res = LifetimeRes :: Anonymous { binder, elided : true } ;
1759
- let mut candidate = LifetimeElisionCandidate :: Missing ( missing_lifetime) ;
1760
- for id in node_ids {
1761
- self . record_lifetime_res (
1762
- id,
1763
- res,
1764
- replace ( & mut candidate, LifetimeElisionCandidate :: Ignore ) ,
1765
- ) ;
1766
- }
1767
- break ;
1768
- }
1769
1743
LifetimeRibKind :: Elided ( res) => {
1770
1744
let mut candidate = LifetimeElisionCandidate :: Missing ( missing_lifetime) ;
1771
1745
for id in node_ids {
@@ -2272,7 +2246,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2272
2246
this. visit_ty ( ty) ;
2273
2247
} ) ;
2274
2248
this. with_lifetime_rib (
2275
- LifetimeRibKind :: AnonymousPassThrough ( item. id ) ,
2249
+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : item. id } ) ,
2276
2250
|this| {
2277
2251
if let Some ( expr) = expr {
2278
2252
let constant_item_kind = match item. kind {
@@ -2547,7 +2521,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2547
2521
// Type parameters can already be used and as associated consts are
2548
2522
// not used as part of the type system, this is far less surprising.
2549
2523
self . with_lifetime_rib (
2550
- LifetimeRibKind :: AnonymousPassThrough ( item. id ) ,
2524
+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : item. id } ) ,
2551
2525
|this| {
2552
2526
this. with_constant_rib (
2553
2527
IsRepeatExpr :: No ,
@@ -2721,7 +2695,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2721
2695
// Type parameters can already be used and as associated consts are
2722
2696
// not used as part of the type system, this is far less surprising.
2723
2697
self . with_lifetime_rib (
2724
- LifetimeRibKind :: AnonymousPassThrough ( item. id ) ,
2698
+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : item. id } ) ,
2725
2699
|this| {
2726
2700
this. with_constant_rib (
2727
2701
IsRepeatExpr :: No ,
0 commit comments