@@ -19,7 +19,7 @@ use syntax::print::pprust;
19
19
use syntax:: util:: lev_distance:: find_best_match_for_name;
20
20
21
21
use crate :: imports:: { ImportDirective , ImportDirectiveSubclass , ImportResolver } ;
22
- use crate :: lifetimes:: { HRLTSpanType , MissingLifetimeSpot } ;
22
+ use crate :: lifetimes:: { ElisionFailureInfo , HRLTSpanType , MissingLifetimeSpot } ;
23
23
use crate :: path_names_to_string;
24
24
use crate :: { AmbiguityError , AmbiguityErrorMisc , AmbiguityKind } ;
25
25
use crate :: { BindingError , CrateLint , HasGenericParams , LegacyScope , Module , ModuleOrUniformRoot } ;
@@ -1462,11 +1462,13 @@ crate fn report_missing_lifetime_specifiers(
1462
1462
1463
1463
crate fn add_missing_lifetime_specifiers_label (
1464
1464
err : & mut DiagnosticBuilder < ' _ > ,
1465
+ source_map : & SourceMap ,
1465
1466
span : Span ,
1466
1467
count : usize ,
1467
1468
lifetime_names : & FxHashSet < ast:: Ident > ,
1468
1469
snippet : Option < & str > ,
1469
1470
missing_named_lifetime_spots : & [ MissingLifetimeSpot < ' _ > ] ,
1471
+ params : & [ ElisionFailureInfo ] ,
1470
1472
) {
1471
1473
if count > 1 {
1472
1474
err. span_label ( span, format ! ( "expected {} lifetime parameters" , count) ) ;
@@ -1509,6 +1511,14 @@ crate fn add_missing_lifetime_specifiers_label(
1509
1511
( * span, suggestion. to_string ( ) )
1510
1512
}
1511
1513
} ) ;
1514
+ for param in params {
1515
+ if let Ok ( snippet) = source_map. span_to_snippet ( param. span ) {
1516
+ if snippet. starts_with ( "&" ) && !snippet. starts_with ( "&'" ) {
1517
+ introduce_suggestion
1518
+ . push ( ( param. span , format ! ( "&'lifetime {}" , & snippet[ 1 ..] ) ) ) ;
1519
+ }
1520
+ }
1521
+ }
1512
1522
introduce_suggestion. push ( ( span, sugg. to_string ( ) ) ) ;
1513
1523
err. multipart_suggestion ( msg, introduce_suggestion, Applicability :: MaybeIncorrect ) ;
1514
1524
if should_break {
0 commit comments