@@ -865,7 +865,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
865
865
let previous_state = replace ( & mut this. in_func_body , true ) ;
866
866
// Resolve the function body, potentially inside the body of an async closure
867
867
this. with_lifetime_rib (
868
- LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : fn_id } ) ,
868
+ LifetimeRibKind :: Elided ( LifetimeRes :: Infer ) ,
869
869
|this| this. visit_block ( body) ,
870
870
) ;
871
871
@@ -893,9 +893,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
893
893
this. with_lifetime_rib (
894
894
match binder {
895
895
ClosureBinder :: NotPresent => {
896
- LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous {
897
- binder : fn_id,
898
- } )
896
+ LifetimeRibKind :: Elided ( LifetimeRes :: Infer )
899
897
}
900
898
ClosureBinder :: For { .. } => LifetimeRibKind :: AnonymousReportError ,
901
899
} ,
@@ -907,7 +905,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
907
905
let previous_state = replace ( & mut this. in_func_body , true ) ;
908
906
// Resolve the function body, potentially inside the body of an async closure
909
907
this. with_lifetime_rib (
910
- LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : fn_id } ) ,
908
+ LifetimeRibKind :: Elided ( LifetimeRes :: Infer ) ,
911
909
|this| this. visit_expr ( body) ,
912
910
) ;
913
911
@@ -1645,35 +1643,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1645
1643
1646
1644
if !missing {
1647
1645
// Do not create a parameter for patterns and expressions.
1648
- for rib in self . lifetime_ribs . iter ( ) . rev ( ) {
1649
- match rib. kind {
1650
- LifetimeRibKind :: Elided ( res @ LifetimeRes :: Anonymous { .. } ) => {
1651
- for id in node_ids {
1652
- self . record_lifetime_res ( id, res, LifetimeElisionCandidate :: Named ) ;
1653
- }
1654
- break ;
1655
- }
1656
- // `LifetimeRes::Error`, which would usually be used in the case of
1657
- // `ReportError`, is unsuitable here, as we don't emit an error yet. Instead,
1658
- // we simply resolve to an implicit lifetime, which will be checked later, at
1659
- // which point a suitable error will be emitted.
1660
- LifetimeRibKind :: AnonymousReportError | LifetimeRibKind :: Item => {
1661
- // FIXME(cjgillot) This resolution is wrong, but this does not matter
1662
- // since these cases are erroneous anyway. Lifetime resolution should
1663
- // emit a "missing lifetime specifier" diagnostic.
1664
- let res = LifetimeRes :: Anonymous { binder : DUMMY_NODE_ID } ;
1665
- for id in node_ids {
1666
- self . record_lifetime_res ( id, res, LifetimeElisionCandidate :: Named ) ;
1667
- }
1668
- break ;
1669
- }
1670
- LifetimeRibKind :: AnonymousCreateParameter { .. }
1671
- | LifetimeRibKind :: Elided ( _)
1672
- | LifetimeRibKind :: ElisionFailure
1673
- | LifetimeRibKind :: Generics { .. }
1674
- | LifetimeRibKind :: ConstGeneric
1675
- | LifetimeRibKind :: AnonConst => { }
1676
- }
1646
+ for id in node_ids {
1647
+ self . record_lifetime_res (
1648
+ id,
1649
+ LifetimeRes :: Infer ,
1650
+ LifetimeElisionCandidate :: Named ,
1651
+ ) ;
1677
1652
}
1678
1653
continue ;
1679
1654
}
@@ -1814,15 +1789,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1814
1789
)
1815
1790
}
1816
1791
match res {
1817
- LifetimeRes :: Param { .. }
1818
- | LifetimeRes :: Fresh { .. }
1819
- | LifetimeRes :: Anonymous { .. }
1820
- | LifetimeRes :: Static => {
1792
+ LifetimeRes :: Param { .. } | LifetimeRes :: Fresh { .. } | LifetimeRes :: Static => {
1821
1793
if let Some ( ref mut candidates) = self . lifetime_elision_candidates {
1822
1794
candidates. insert ( res, candidate) ;
1823
1795
}
1824
1796
}
1825
- LifetimeRes :: Error | LifetimeRes :: ElidedAnchor { .. } => { }
1797
+ LifetimeRes :: Infer | LifetimeRes :: Error | LifetimeRes :: ElidedAnchor { .. } => { }
1826
1798
}
1827
1799
}
1828
1800
@@ -2245,26 +2217,23 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2245
2217
this. with_lifetime_rib ( LifetimeRibKind :: Elided ( LifetimeRes :: Static ) , |this| {
2246
2218
this. visit_ty ( ty) ;
2247
2219
} ) ;
2248
- this. with_lifetime_rib (
2249
- LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : item. id } ) ,
2250
- |this| {
2251
- if let Some ( expr) = expr {
2252
- let constant_item_kind = match item. kind {
2253
- ItemKind :: Const ( ..) => ConstantItemKind :: Const ,
2254
- ItemKind :: Static ( ..) => ConstantItemKind :: Static ,
2255
- _ => unreachable ! ( ) ,
2256
- } ;
2257
- // We already forbid generic params because of the above item rib,
2258
- // so it doesn't matter whether this is a trivial constant.
2259
- this. with_constant_rib (
2260
- IsRepeatExpr :: No ,
2261
- HasGenericParams :: Yes ,
2262
- Some ( ( item. ident , constant_item_kind) ) ,
2263
- |this| this. visit_expr ( expr) ,
2264
- ) ;
2265
- }
2266
- } ,
2267
- ) ;
2220
+ this. with_lifetime_rib ( LifetimeRibKind :: Elided ( LifetimeRes :: Infer ) , |this| {
2221
+ if let Some ( expr) = expr {
2222
+ let constant_item_kind = match item. kind {
2223
+ ItemKind :: Const ( ..) => ConstantItemKind :: Const ,
2224
+ ItemKind :: Static ( ..) => ConstantItemKind :: Static ,
2225
+ _ => unreachable ! ( ) ,
2226
+ } ;
2227
+ // We already forbid generic params because of the above item rib,
2228
+ // so it doesn't matter whether this is a trivial constant.
2229
+ this. with_constant_rib (
2230
+ IsRepeatExpr :: No ,
2231
+ HasGenericParams :: Yes ,
2232
+ Some ( ( item. ident , constant_item_kind) ) ,
2233
+ |this| this. visit_expr ( expr) ,
2234
+ ) ;
2235
+ }
2236
+ } ) ;
2268
2237
} ) ;
2269
2238
}
2270
2239
@@ -2521,7 +2490,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2521
2490
// Type parameters can already be used and as associated consts are
2522
2491
// not used as part of the type system, this is far less surprising.
2523
2492
self . with_lifetime_rib (
2524
- LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : item . id } ) ,
2493
+ LifetimeRibKind :: Elided ( LifetimeRes :: Infer ) ,
2525
2494
|this| {
2526
2495
this. with_constant_rib (
2527
2496
IsRepeatExpr :: No ,
@@ -2694,17 +2663,14 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
2694
2663
//
2695
2664
// Type parameters can already be used and as associated consts are
2696
2665
// not used as part of the type system, this is far less surprising.
2697
- self . with_lifetime_rib (
2698
- LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : item. id } ) ,
2699
- |this| {
2700
- this. with_constant_rib (
2701
- IsRepeatExpr :: No ,
2702
- HasGenericParams :: Yes ,
2703
- None ,
2704
- |this| this. visit_expr ( expr) ,
2705
- )
2706
- } ,
2707
- ) ;
2666
+ self . with_lifetime_rib ( LifetimeRibKind :: Elided ( LifetimeRes :: Infer ) , |this| {
2667
+ this. with_constant_rib (
2668
+ IsRepeatExpr :: No ,
2669
+ HasGenericParams :: Yes ,
2670
+ None ,
2671
+ |this| this. visit_expr ( expr) ,
2672
+ )
2673
+ } ) ;
2708
2674
}
2709
2675
}
2710
2676
AssocItemKind :: Fn ( box Fn { generics, .. } ) => {
0 commit comments