@@ -155,7 +155,7 @@ struct NamedRegionMap {
155155
156156crate enum MissingLifetimeSpot < ' tcx > {
157157 Generics ( & ' tcx hir:: Generics < ' tcx > ) ,
158- HRLT { span : Span , span_type : ForLifetimeSpanType } ,
158+ HigherRanked { span : Span , span_type : ForLifetimeSpanType } ,
159159}
160160
161161crate enum ForLifetimeSpanType {
@@ -165,6 +165,22 @@ crate enum ForLifetimeSpanType {
165165 TypeTail ,
166166}
167167
168+ impl ForLifetimeSpanType {
169+ crate fn descr ( & self ) -> & ' static str {
170+ match self {
171+ Self :: BoundEmpty | Self :: BoundTail => "bound" ,
172+ Self :: TypeEmpty | Self :: TypeTail => "type" ,
173+ }
174+ }
175+
176+ crate fn suggestion ( & self , sugg : & str ) -> String {
177+ match self {
178+ Self :: BoundEmpty | Self :: TypeEmpty => format ! ( "for<{}> " , sugg) ,
179+ Self :: BoundTail | Self :: TypeTail => format ! ( ", {}" , sugg) ,
180+ }
181+ }
182+ }
183+
168184impl < ' tcx > Into < MissingLifetimeSpot < ' tcx > > for & ' tcx hir:: Generics < ' tcx > {
169185 fn into ( self ) -> MissingLifetimeSpot < ' tcx > {
170186 MissingLifetimeSpot :: Generics ( self )
@@ -525,7 +541,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
525541 ( ty. span . shrink_to_lo ( ) , ForLifetimeSpanType :: TypeEmpty )
526542 } ;
527543 self . missing_named_lifetime_spots
528- . push ( MissingLifetimeSpot :: HRLT { span, span_type } ) ;
544+ . push ( MissingLifetimeSpot :: HigherRanked { span, span_type } ) ;
529545 let scope = Scope :: Binder {
530546 lifetimes : c
531547 . generic_params
@@ -1887,29 +1903,15 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
18871903 Applicability :: MaybeIncorrect ,
18881904 ) ;
18891905 }
1890- MissingLifetimeSpot :: HRLT { span, span_type } => {
1906+ MissingLifetimeSpot :: HigherRanked { span, span_type } => {
18911907 err. span_suggestion (
18921908 * span,
18931909 & format ! (
18941910 "consider making the {} lifetime-generic with a new `{}` lifetime" ,
1895- match span_type {
1896- ForLifetimeSpanType :: BoundEmpty
1897- | ForLifetimeSpanType :: BoundTail => "bound" ,
1898- ForLifetimeSpanType :: TypeEmpty
1899- | ForLifetimeSpanType :: TypeTail => "type" ,
1900- } ,
1911+ span_type. descr( ) ,
19011912 lifetime_ref
19021913 ) ,
1903- match span_type {
1904- ForLifetimeSpanType :: TypeEmpty
1905- | ForLifetimeSpanType :: BoundEmpty => {
1906- format ! ( "for<{}> " , lifetime_ref)
1907- }
1908- ForLifetimeSpanType :: TypeTail | ForLifetimeSpanType :: BoundTail => {
1909- format ! ( ", {}" , lifetime_ref)
1910- }
1911- }
1912- . to_string ( ) ,
1914+ span_type. suggestion ( & lifetime_ref. to_string ( ) ) ,
19131915 Applicability :: MaybeIncorrect ,
19141916 ) ;
19151917 err. note (
@@ -2840,7 +2842,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
28402842 [ .., bound] => ( bound. span . shrink_to_hi ( ) , ForLifetimeSpanType :: BoundTail ) ,
28412843 } ;
28422844 self . missing_named_lifetime_spots
2843- . push ( MissingLifetimeSpot :: HRLT { span, span_type } ) ;
2845+ . push ( MissingLifetimeSpot :: HigherRanked { span, span_type } ) ;
28442846 return true ;
28452847 }
28462848 } ;
0 commit comments