@@ -83,7 +83,7 @@ impl ForLifetimeSpanType {
83
83
}
84
84
}
85
85
86
- pub ( crate ) fn suggestion ( & self , sugg : & str ) -> String {
86
+ pub ( crate ) fn suggestion ( & self , sugg : impl std :: fmt :: Display ) -> String {
87
87
match self {
88
88
Self :: BoundEmpty | Self :: TypeEmpty => format ! ( "for<{}> " , sugg) ,
89
89
Self :: ClosureEmpty => format ! ( "for<{}>" , sugg) ,
@@ -2313,8 +2313,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
2313
2313
2314
2314
let suggest_existing =
2315
2315
|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 > > > | {
2318
2318
if let Some ( MissingLifetimeSpot :: HigherRanked { span : for_span, span_type } ) =
2319
2319
self . missing_named_lifetime_spots . iter ( ) . rev ( ) . next ( )
2320
2320
{
@@ -2334,7 +2334,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
2334
2334
// If all single char lifetime names are present, we wrap around and double the chars.
2335
2335
let lt_name = ( 1 ..)
2336
2336
. 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) )
2338
2339
. unwrap ( ) ;
2339
2340
let msg = format ! (
2340
2341
"consider making the {} lifetime-generic with a new `{}` lifetime" ,
@@ -2361,7 +2362,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
2361
2362
introduce_suggestion. push ( ( * for_span, for_sugg) ) ;
2362
2363
for ( ( span, _) , formatter) in spans_with_counts. iter ( ) . zip ( formatters. iter ( ) ) {
2363
2364
if let Some ( formatter) = formatter {
2364
- introduce_suggestion. push ( ( * span, formatter ( & lt_name) ) ) ;
2365
+ introduce_suggestion. push ( ( * span, formatter ( lt_name) ) ) ;
2365
2366
}
2366
2367
}
2367
2368
err. multipart_suggestion_verbose (
@@ -2584,15 +2585,19 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
2584
2585
let lifetime_names: Vec < _ > = lifetime_names. iter ( ) . collect ( ) ;
2585
2586
match & lifetime_names[ ..] {
2586
2587
[ 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 ( ) ;
2588
2589
for ( snippet, ( _, count) ) in snippets. iter ( ) . zip ( spans_with_counts. iter ( ) . copied ( ) )
2589
2590
{
2590
2591
suggs. push ( match snippet. as_deref ( ) {
2591
2592
Some ( "&" ) => Some ( Box :: new ( |name| format ! ( "&{} " , name) ) ) ,
2592
2593
Some ( "'_" ) => Some ( Box :: new ( |n| n. to_string ( ) ) ) ,
2593
2594
Some ( "" ) => Some ( Box :: new ( move |n| format ! ( "{}, " , n) . repeat ( count) ) ) ,
2594
2595
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 ( ", " )
2596
2601
} ) ) ,
2597
2602
Some ( snippet) if !snippet. ends_with ( '>' ) => Some ( Box :: new ( move |name| {
2598
2603
format ! (
@@ -2607,7 +2612,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
2607
2612
_ => None ,
2608
2613
} ) ;
2609
2614
}
2610
- suggest_existing ( err, name. as_str ( ) , suggs) ;
2615
+ suggest_existing ( err, * * name, suggs) ;
2611
2616
}
2612
2617
[ ] => {
2613
2618
let mut suggs = Vec :: new ( ) ;
0 commit comments