@@ -262,9 +262,6 @@ enum LifetimeRibKind {
262262 /// error on default object bounds (e.g., `Box<dyn Foo>`).
263263 AnonymousReportError ,
264264
265- /// Pass responsibility to `resolve_lifetime` code for all cases.
266- AnonymousPassThrough ( NodeId ) ,
267-
268265 /// Replace all anonymous lifetimes by provided lifetime.
269266 Elided ( LifetimeRes ) ,
270267
@@ -868,7 +865,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
868865 let previous_state = replace ( & mut this. in_func_body , true ) ;
869866 // Resolve the function body, potentially inside the body of an async closure
870867 this. with_lifetime_rib (
871- LifetimeRibKind :: AnonymousPassThrough ( fn_id) ,
868+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : fn_id } ) ,
872869 |this| this. visit_block ( body) ,
873870 ) ;
874871
@@ -896,7 +893,9 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
896893 this. with_lifetime_rib (
897894 match binder {
898895 ClosureBinder :: NotPresent => {
899- LifetimeRibKind :: AnonymousPassThrough ( fn_id)
896+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous {
897+ binder : fn_id,
898+ } )
900899 }
901900 ClosureBinder :: For { .. } => LifetimeRibKind :: AnonymousReportError ,
902901 } ,
@@ -908,7 +907,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
908907 let previous_state = replace ( & mut this. in_func_body , true ) ;
909908 // Resolve the function body, potentially inside the body of an async closure
910909 this. with_lifetime_rib (
911- LifetimeRibKind :: AnonymousPassThrough ( fn_id) ,
910+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : fn_id } ) ,
912911 |this| this. visit_expr ( body) ,
913912 ) ;
914913
@@ -1053,8 +1052,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
10531052 visit:: walk_generic_args ( self , path_span, args) ;
10541053 break ;
10551054 }
1056- LifetimeRibKind :: AnonymousPassThrough ( ..)
1057- | LifetimeRibKind :: AnonymousCreateParameter { .. }
1055+ LifetimeRibKind :: AnonymousCreateParameter { .. }
10581056 | LifetimeRibKind :: AnonymousReportError
10591057 | LifetimeRibKind :: Elided ( _)
10601058 | LifetimeRibKind :: ElisionFailure
@@ -1415,8 +1413,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
14151413 | LifetimeRibKind :: AnonymousReportError
14161414 | LifetimeRibKind :: ElisionFailure => Some ( LifetimeUseSet :: Many ) ,
14171415 // An anonymous lifetime is legal here, go ahead.
1418- LifetimeRibKind :: AnonymousPassThrough ( _)
1419- | LifetimeRibKind :: AnonymousCreateParameter { .. } => {
1416+ LifetimeRibKind :: AnonymousCreateParameter { .. } => {
14201417 Some ( LifetimeUseSet :: One { use_span : ident. span , use_ctxt } )
14211418 }
14221419 // Only report if eliding the lifetime would have the same
@@ -1527,14 +1524,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
15271524 self . record_lifetime_res ( lifetime. id , LifetimeRes :: Error , elision_candidate) ;
15281525 return ;
15291526 }
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- }
15381527 LifetimeRibKind :: Elided ( res) => {
15391528 self . record_lifetime_res ( lifetime. id , res, elision_candidate) ;
15401529 return ;
@@ -1658,8 +1647,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
16581647 // Do not create a parameter for patterns and expressions.
16591648 for rib in self . lifetime_ribs . iter ( ) . rev ( ) {
16601649 match rib. kind {
1661- LifetimeRibKind :: AnonymousPassThrough ( binder) => {
1662- let res = LifetimeRes :: Anonymous { binder, elided : true } ;
1650+ LifetimeRibKind :: Elided ( res @ LifetimeRes :: Anonymous { .. } ) => {
16631651 for id in node_ids {
16641652 self . record_lifetime_res ( id, res, LifetimeElisionCandidate :: Named ) ;
16651653 }
@@ -1673,8 +1661,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
16731661 // FIXME(cjgillot) This resolution is wrong, but this does not matter
16741662 // since these cases are erroneous anyway. Lifetime resolution should
16751663 // 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 } ;
16781665 for id in node_ids {
16791666 self . record_lifetime_res ( id, res, LifetimeElisionCandidate :: Named ) ;
16801667 }
@@ -1753,19 +1740,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
17531740 }
17541741 break ;
17551742 }
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- }
17691743 LifetimeRibKind :: Elided ( res) => {
17701744 let mut candidate = LifetimeElisionCandidate :: Missing ( missing_lifetime) ;
17711745 for id in node_ids {
@@ -2272,7 +2246,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
22722246 this. visit_ty ( ty) ;
22732247 } ) ;
22742248 this. with_lifetime_rib (
2275- LifetimeRibKind :: AnonymousPassThrough ( item. id ) ,
2249+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : item. id } ) ,
22762250 |this| {
22772251 if let Some ( expr) = expr {
22782252 let constant_item_kind = match item. kind {
@@ -2547,7 +2521,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
25472521 // Type parameters can already be used and as associated consts are
25482522 // not used as part of the type system, this is far less surprising.
25492523 self . with_lifetime_rib (
2550- LifetimeRibKind :: AnonymousPassThrough ( item. id ) ,
2524+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : item. id } ) ,
25512525 |this| {
25522526 this. with_constant_rib (
25532527 IsRepeatExpr :: No ,
@@ -2721,7 +2695,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
27212695 // Type parameters can already be used and as associated consts are
27222696 // not used as part of the type system, this is far less surprising.
27232697 self . with_lifetime_rib (
2724- LifetimeRibKind :: AnonymousPassThrough ( item. id ) ,
2698+ LifetimeRibKind :: Elided ( LifetimeRes :: Anonymous { binder : item. id } ) ,
27252699 |this| {
27262700 this. with_constant_rib (
27272701 IsRepeatExpr :: No ,
0 commit comments