@@ -80,7 +80,7 @@ impl ForLifetimeSpanType {
8080 }
8181 }
8282
83- pub ( crate ) fn suggestion ( & self , sugg : & str ) -> String {
83+ pub ( crate ) fn suggestion ( & self , sugg : impl std :: fmt :: Display ) -> String {
8484 match self {
8585 Self :: BoundEmpty | Self :: TypeEmpty => format ! ( "for<{}> " , sugg) ,
8686 Self :: BoundTail | Self :: TypeTail => format ! ( ", {}" , sugg) ,
@@ -2311,8 +2311,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
23112311
23122312 let suggest_existing =
23132313 |err : & mut Diagnostic ,
2314- name : & str ,
2315- formatters : Vec < Option < Box < dyn Fn ( & str ) -> String > > > | {
2314+ name : Symbol ,
2315+ formatters : Vec < Option < Box < dyn Fn ( Symbol ) -> String > > > | {
23162316 if let Some ( MissingLifetimeSpot :: HigherRanked { span : for_span, span_type } ) =
23172317 self . missing_named_lifetime_spots . iter ( ) . rev ( ) . next ( )
23182318 {
@@ -2332,7 +2332,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
23322332 // If all single char lifetime names are present, we wrap around and double the chars.
23332333 let lt_name = ( 1 ..)
23342334 . flat_map ( a_to_z_repeat_n)
2335- . find ( |lt| !lifetime_names. contains ( & Symbol :: intern ( & lt) ) )
2335+ . map ( |lt| Symbol :: intern ( & lt) )
2336+ . find ( |lt| !lifetime_names. contains ( lt) )
23362337 . unwrap ( ) ;
23372338 let msg = format ! (
23382339 "consider making the {} lifetime-generic with a new `{}` lifetime" ,
@@ -2359,7 +2360,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
23592360 introduce_suggestion. push ( ( * for_span, for_sugg) ) ;
23602361 for ( ( span, _) , formatter) in spans_with_counts. iter ( ) . zip ( formatters. iter ( ) ) {
23612362 if let Some ( formatter) = formatter {
2362- introduce_suggestion. push ( ( * span, formatter ( & lt_name) ) ) ;
2363+ introduce_suggestion. push ( ( * span, formatter ( lt_name) ) ) ;
23632364 }
23642365 }
23652366 err. multipart_suggestion_verbose (
@@ -2582,15 +2583,19 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
25822583 let lifetime_names: Vec < _ > = lifetime_names. iter ( ) . collect ( ) ;
25832584 match & lifetime_names[ ..] {
25842585 [ name] => {
2585- let mut suggs: Vec < Option < Box < dyn Fn ( & str ) -> String > > > = Vec :: new ( ) ;
2586+ let mut suggs: Vec < Option < Box < dyn Fn ( Symbol ) -> String > > > = Vec :: new ( ) ;
25862587 for ( snippet, ( _, count) ) in snippets. iter ( ) . zip ( spans_with_counts. iter ( ) . copied ( ) )
25872588 {
25882589 suggs. push ( match snippet. as_deref ( ) {
25892590 Some ( "&" ) => Some ( Box :: new ( |name| format ! ( "&{} " , name) ) ) ,
25902591 Some ( "'_" ) => Some ( Box :: new ( |n| n. to_string ( ) ) ) ,
25912592 Some ( "" ) => Some ( Box :: new ( move |n| format ! ( "{}, " , n) . repeat ( count) ) ) ,
25922593 Some ( "<" ) => Some ( Box :: new ( move |n| {
2593- std:: iter:: repeat ( n) . take ( count) . collect :: < Vec < _ > > ( ) . join ( ", " )
2594+ std:: iter:: repeat ( n)
2595+ . take ( count)
2596+ . map ( |n| n. to_string ( ) )
2597+ . collect :: < Vec < _ > > ( )
2598+ . join ( ", " )
25942599 } ) ) ,
25952600 Some ( snippet) if !snippet. ends_with ( '>' ) => Some ( Box :: new ( move |name| {
25962601 format ! (
@@ -2605,7 +2610,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
26052610 _ => None ,
26062611 } ) ;
26072612 }
2608- suggest_existing ( err, name. as_str ( ) , suggs) ;
2613+ suggest_existing ( err, * * name, suggs) ;
26092614 }
26102615 [ ] => {
26112616 let mut suggs = Vec :: new ( ) ;
0 commit comments