@@ -1423,9 +1423,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
14231423 } else {
14241424 LifetimeUseSet :: Many
14251425 } ) ,
1426- LifetimeRibKind :: Generics { .. }
1427- | LifetimeRibKind :: ConstGeneric
1428- | LifetimeRibKind :: AnonConst => None ,
1426+ LifetimeRibKind :: Generics { .. } => None ,
1427+ LifetimeRibKind :: ConstGeneric | LifetimeRibKind :: AnonConst => {
1428+ span_bug ! ( ident. span, "unexpected rib kind: {:?}" , rib. kind)
1429+ }
14291430 } )
14301431 . unwrap_or ( LifetimeUseSet :: Many ) ;
14311432 debug ! ( ?use_ctxt, ?use_set) ;
@@ -1460,7 +1461,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
14601461 ) ;
14611462 return ;
14621463 }
1463- _ => { }
1464+ LifetimeRibKind :: AnonymousCreateParameter { .. }
1465+ | LifetimeRibKind :: Elided ( _)
1466+ | LifetimeRibKind :: Generics { .. }
1467+ | LifetimeRibKind :: ElisionFailure
1468+ | LifetimeRibKind :: AnonymousReportError => { }
14641469 }
14651470 }
14661471
@@ -1534,9 +1539,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
15341539 return ;
15351540 }
15361541 LifetimeRibKind :: Item => break ,
1537- LifetimeRibKind :: Generics { .. }
1538- | LifetimeRibKind :: ConstGeneric
1539- | LifetimeRibKind :: AnonConst => { }
1542+ LifetimeRibKind :: Generics { .. } | LifetimeRibKind :: ConstGeneric => { }
1543+ LifetimeRibKind :: AnonConst => {
1544+ // There is always an `Elided(LifetimeRes::Static)` inside an `AnonConst`.
1545+ span_bug ! ( lifetime. ident. span, "unexpected rib kind: {:?}" , rib. kind)
1546+ }
15401547 }
15411548 }
15421549 self . record_lifetime_res ( lifetime. id , LifetimeRes :: Error , elision_candidate) ;
@@ -1751,9 +1758,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
17511758 self . report_missing_lifetime_specifiers ( vec ! [ missing_lifetime] , None ) ;
17521759 break ;
17531760 }
1754- LifetimeRibKind :: Generics { .. }
1755- | LifetimeRibKind :: ConstGeneric
1756- | LifetimeRibKind :: AnonConst => { }
1761+ LifetimeRibKind :: Generics { .. } | LifetimeRibKind :: ConstGeneric => { }
1762+ LifetimeRibKind :: AnonConst => {
1763+ // There is always an `Elided(LifetimeRes::Static)` inside an `AnonConst`.
1764+ span_bug ! ( elided_lifetime_span, "unexpected rib kind: {:?}" , rib. kind)
1765+ }
17571766 }
17581767 }
17591768
@@ -3938,7 +3947,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
39383947 fn_id : NodeId ,
39393948 async_node_id : Option < ( NodeId , Span ) > ,
39403949 ) {
3941- if let Some ( ( async_node_id, _ ) ) = async_node_id {
3950+ if let Some ( ( async_node_id, span ) ) = async_node_id {
39423951 let mut extra_lifetime_params =
39433952 self . r . extra_lifetime_params_map . get ( & fn_id) . cloned ( ) . unwrap_or_default ( ) ;
39443953 for rib in self . lifetime_ribs . iter ( ) . rev ( ) {
@@ -3952,7 +3961,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
39523961 extra_lifetime_params. extend ( earlier_fresh) ;
39533962 }
39543963 }
3955- _ => { }
3964+ LifetimeRibKind :: Generics { .. } => { }
3965+ _ => {
3966+ // We are in a function definition. We should only find `Generics`
3967+ // and `AnonymousCreateParameter` inside the innermost `Item`.
3968+ span_bug ! ( span, "unexpected rib kind: {:?}" , rib. kind)
3969+ }
39563970 }
39573971 }
39583972 self . r . extra_lifetime_params_map . insert ( async_node_id, extra_lifetime_params) ;
0 commit comments