@@ -83,7 +83,7 @@ impl ForLifetimeSpanType {
8383 }
8484 }
8585
86- pub ( crate ) fn suggestion ( & self , sugg : & str ) -> String {
86+ pub ( crate ) fn suggestion ( & self , sugg : impl std :: fmt :: Display ) -> String {
8787 match self {
8888 Self :: BoundEmpty | Self :: TypeEmpty => format ! ( "for<{}> " , sugg) ,
8989 Self :: ClosureEmpty => format ! ( "for<{}>" , sugg) ,
@@ -2313,8 +2313,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
23132313
23142314 let suggest_existing =
23152315 |err : & mut Diagnostic ,
2316- name : & str ,
2317- formatters : Vec < Option < Box < dyn Fn ( & str ) -> String > > > | {
2316+ name : Symbol ,
2317+ formatters : Vec < Option < Box < dyn Fn ( Symbol ) -> String > > > | {
23182318 if let Some ( MissingLifetimeSpot :: HigherRanked { span : for_span, span_type } ) =
23192319 self . missing_named_lifetime_spots . iter ( ) . rev ( ) . next ( )
23202320 {
@@ -2334,7 +2334,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
23342334 // If all single char lifetime names are present, we wrap around and double the chars.
23352335 let lt_name = ( 1 ..)
23362336 . flat_map ( a_to_z_repeat_n)
2337- . find ( |lt| !lifetime_names. contains ( & Symbol :: intern ( & lt) ) )
2337+ . map ( |lt| Symbol :: intern ( & lt) )
2338+ . find ( |lt| !lifetime_names. contains ( lt) )
23382339 . unwrap ( ) ;
23392340 let msg = format ! (
23402341 "consider making the {} lifetime-generic with a new `{}` lifetime" ,
@@ -2361,7 +2362,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
23612362 introduce_suggestion. push ( ( * for_span, for_sugg) ) ;
23622363 for ( ( span, _) , formatter) in spans_with_counts. iter ( ) . zip ( formatters. iter ( ) ) {
23632364 if let Some ( formatter) = formatter {
2364- introduce_suggestion. push ( ( * span, formatter ( & lt_name) ) ) ;
2365+ introduce_suggestion. push ( ( * span, formatter ( lt_name) ) ) ;
23652366 }
23662367 }
23672368 err. multipart_suggestion_verbose (
@@ -2584,15 +2585,19 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
25842585 let lifetime_names: Vec < _ > = lifetime_names. iter ( ) . collect ( ) ;
25852586 match & lifetime_names[ ..] {
25862587 [ name] => {
2587- let mut suggs: Vec < Option < Box < dyn Fn ( & str ) -> String > > > = Vec :: new ( ) ;
2588+ let mut suggs: Vec < Option < Box < dyn Fn ( Symbol ) -> String > > > = Vec :: new ( ) ;
25882589 for ( snippet, ( _, count) ) in snippets. iter ( ) . zip ( spans_with_counts. iter ( ) . copied ( ) )
25892590 {
25902591 suggs. push ( match snippet. as_deref ( ) {
25912592 Some ( "&" ) => Some ( Box :: new ( |name| format ! ( "&{} " , name) ) ) ,
25922593 Some ( "'_" ) => Some ( Box :: new ( |n| n. to_string ( ) ) ) ,
25932594 Some ( "" ) => Some ( Box :: new ( move |n| format ! ( "{}, " , n) . repeat ( count) ) ) ,
25942595 Some ( "<" ) => Some ( Box :: new ( move |n| {
2595- std:: iter:: repeat ( n) . take ( count) . collect :: < Vec < _ > > ( ) . join ( ", " )
2596+ std:: iter:: repeat ( n)
2597+ . take ( count)
2598+ . map ( |n| n. to_string ( ) )
2599+ . collect :: < Vec < _ > > ( )
2600+ . join ( ", " )
25962601 } ) ) ,
25972602 Some ( snippet) if !snippet. ends_with ( '>' ) => Some ( Box :: new ( move |name| {
25982603 format ! (
@@ -2607,7 +2612,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
26072612 _ => None ,
26082613 } ) ;
26092614 }
2610- suggest_existing ( err, name. as_str ( ) , suggs) ;
2615+ suggest_existing ( err, * * name, suggs) ;
26112616 }
26122617 [ ] => {
26132618 let mut suggs = Vec :: new ( ) ;
0 commit comments