@@ -1378,17 +1378,18 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
1378
1378
}
1379
1379
} ;
1380
1380
1381
- match ( lifetime_names. len ( ) , lifetime_names. iter ( ) . next ( ) , snippet. as_deref ( ) ) {
1382
- ( 1 , Some ( name) , Some ( "&" ) ) => {
1381
+ let lifetime_names: Vec < _ > = lifetime_names. into_iter ( ) . collect ( ) ;
1382
+ match ( & lifetime_names[ ..] , snippet. as_deref ( ) ) {
1383
+ ( [ name] , Some ( "&" ) ) => {
1383
1384
suggest_existing ( err, & name. as_str ( ) [ ..] , & |name| format ! ( "&{} " , name) ) ;
1384
1385
}
1385
- ( 1 , Some ( name) , Some ( "'_" ) ) => {
1386
+ ( [ name] , Some ( "'_" ) ) => {
1386
1387
suggest_existing ( err, & name. as_str ( ) [ ..] , & |n| n. to_string ( ) ) ;
1387
1388
}
1388
- ( 1 , Some ( name) , Some ( "" ) ) => {
1389
+ ( [ name] , Some ( "" ) ) => {
1389
1390
suggest_existing ( err, & name. as_str ( ) [ ..] , & |n| format ! ( "{}, " , n) . repeat ( count) ) ;
1390
1391
}
1391
- ( 1 , Some ( name) , Some ( snippet) ) if !snippet. ends_with ( '>' ) => {
1392
+ ( [ name] , Some ( snippet) ) if !snippet. ends_with ( '>' ) => {
1392
1393
let f = |name : & str | {
1393
1394
format ! (
1394
1395
"{}<{}>" ,
@@ -1401,13 +1402,13 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
1401
1402
} ;
1402
1403
suggest_existing ( err, & name. as_str ( ) [ ..] , & f) ;
1403
1404
}
1404
- ( 0 , _ , Some ( "&" ) ) if count == 1 => {
1405
+ ( [ ] , Some ( "&" ) ) if count == 1 => {
1405
1406
suggest_new ( err, "&'a " ) ;
1406
1407
}
1407
- ( 0 , _ , Some ( "'_" ) ) if count == 1 => {
1408
+ ( [ ] , Some ( "'_" ) ) if count == 1 => {
1408
1409
suggest_new ( err, "'a" ) ;
1409
1410
}
1410
- ( 0 , _ , Some ( snippet) ) if !snippet. ends_with ( '>' ) && count == 1 => {
1411
+ ( [ ] , Some ( snippet) ) if !snippet. ends_with ( '>' ) && count == 1 => {
1411
1412
if snippet == "" {
1412
1413
// This happens when we have `type Bar<'a> = Foo<T>` where we point at the space
1413
1414
// before `T`. We will suggest `type Bar<'a> = Foo<'a, T>`.
@@ -1416,7 +1417,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
1416
1417
suggest_new ( err, & format ! ( "{}<'a>" , snippet) ) ;
1417
1418
}
1418
1419
}
1419
- ( n , ..) if n > 1 => {
1420
+ ( lts , ..) if lts . len ( ) > 1 => {
1420
1421
err. span_note ( lifetime_spans, "these named lifetimes are available to use" ) ;
1421
1422
if Some ( "" ) == snippet. as_deref ( ) {
1422
1423
// This happens when we have `Foo<T>` where we point at the space before `T`,
0 commit comments