@@ -11,7 +11,6 @@ use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
11
11
use rustc_span:: symbol:: Ident ;
12
12
use rustc_span:: { Span , Symbol } ;
13
13
14
- use crate :: fluent_generated as fluent;
15
14
use crate :: parser:: { ForbiddenLetReason , TokenDescription } ;
16
15
17
16
#[ derive( Diagnostic ) ]
@@ -498,7 +497,7 @@ pub(crate) struct ExpectedExpressionFoundLet {
498
497
499
498
#[ derive( Subdiagnostic , Clone , Copy ) ]
500
499
#[ multipart_suggestion(
501
- parse_maybe_missing_let ,
500
+ label = "you might have meant to continue the let-chain" ,
502
501
applicability = "maybe-incorrect" ,
503
502
style = "verbose"
504
503
) ]
@@ -509,7 +508,7 @@ pub(crate) struct MaybeMissingLet {
509
508
510
509
#[ derive( Subdiagnostic , Clone , Copy ) ]
511
510
#[ multipart_suggestion(
512
- parse_maybe_comparison ,
511
+ label = "you might have meant to compare for equality" ,
513
512
applicability = "maybe-incorrect" ,
514
513
style = "verbose"
515
514
) ]
@@ -1247,16 +1246,18 @@ impl<'a> IntoDiagnostic<'a> for ExpectedIdentifier {
1247
1246
1248
1247
let mut diag = handler. struct_diagnostic ( match token_descr {
1249
1248
Some ( TokenDescription :: ReservedIdentifier ) => {
1250
- fluent :: parse_expected_identifier_found_reserved_identifier_str
1249
+ "expected identifier, found reserved identifier `{$token}`"
1251
1250
}
1252
- Some ( TokenDescription :: Keyword ) => fluent :: parse_expected_identifier_found_keyword_str ,
1251
+ Some ( TokenDescription :: Keyword ) => "expected identifier, found keyword `{$token}`" ,
1253
1252
Some ( TokenDescription :: ReservedKeyword ) => {
1254
- fluent :: parse_expected_identifier_found_reserved_keyword_str
1253
+ "expected identifier, found reserved keyword `{$token}`"
1255
1254
}
1255
+
1256
1256
Some ( TokenDescription :: DocComment ) => {
1257
- fluent :: parse_expected_identifier_found_doc_comment_str
1257
+ "expected identifier, found doc comment `{$token}`"
1258
1258
}
1259
- None => fluent:: parse_expected_identifier_found_str,
1259
+
1260
+ None => "expected identifier, found `{$token}`" ,
1260
1261
} ) ;
1261
1262
diag. set_span ( self . span ) ;
1262
1263
diag. set_arg ( "token" , self . token ) ;
@@ -1303,28 +1304,21 @@ impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
1303
1304
let token_descr = TokenDescription :: from_token ( & self . token ) ;
1304
1305
1305
1306
let mut diag = handler. struct_diagnostic ( match token_descr {
1306
- Some ( TokenDescription :: ReservedIdentifier ) => DiagnosticMessage :: Str ( Cow :: from (
1307
- "expected `;`, found reserved identifier `{$token}`" ,
1308
- ) ) ,
1309
- Some ( TokenDescription :: Keyword ) => {
1310
- DiagnosticMessage :: Str ( Cow :: from ( "expected `;`, found keyword `{$token}`" ) )
1307
+ Some ( TokenDescription :: ReservedIdentifier ) => {
1308
+ "expected `;`, found reserved identifier `{$token}`"
1311
1309
}
1310
+ Some ( TokenDescription :: Keyword ) => "expected `;`, found keyword `{$token}`" ,
1312
1311
Some ( TokenDescription :: ReservedKeyword ) => {
1313
- DiagnosticMessage :: Str ( Cow :: from ( "expected `;`, found reserved keyword `{$token}`" ) )
1314
- }
1315
- Some ( TokenDescription :: DocComment ) => {
1316
- DiagnosticMessage :: Str ( Cow :: from ( "expected `;`, found doc comment `{$token}`" ) )
1312
+ "expected `;`, found reserved keyword `{$token}`"
1317
1313
}
1318
- None => DiagnosticMessage :: Str ( Cow :: from ( "expected `;`, found `{$token}`" ) ) ,
1314
+ Some ( TokenDescription :: DocComment ) => "expected `;`, found doc comment `{$token}`" ,
1315
+ None => "expected `;`, found `{$token}`" ,
1319
1316
} ) ;
1320
1317
diag. set_span ( self . span ) ;
1321
1318
diag. set_arg ( "token" , self . token ) ;
1322
1319
1323
1320
if let Some ( unexpected_token_label) = self . unexpected_token_label {
1324
- diag. span_label (
1325
- unexpected_token_label,
1326
- DiagnosticMessage :: Str ( Cow :: from ( "unexpected token" ) ) ,
1327
- ) ;
1321
+ diag. span_label ( unexpected_token_label, "unexpected token" ) ;
1328
1322
}
1329
1323
1330
1324
self . sugg . add_to_diagnostic ( & mut diag) ;
@@ -1518,7 +1512,7 @@ pub(crate) struct ParenthesesInForHeadSugg {
1518
1512
}
1519
1513
1520
1514
#[ derive( Diagnostic ) ]
1521
- #[ diag( parse_unexpected_parentheses_in_match_arm_pattern ) ]
1515
+ #[ diag( "unexpected parentheses surrounding `match` arm pattern" ) ]
1522
1516
pub ( crate ) struct ParenthesesInMatchPat {
1523
1517
#[ primary_span]
1524
1518
pub span : Vec < Span > ,
@@ -1527,7 +1521,7 @@ pub(crate) struct ParenthesesInMatchPat {
1527
1521
}
1528
1522
1529
1523
#[ derive( Subdiagnostic ) ]
1530
- #[ multipart_suggestion( parse_suggestion , applicability = "machine-applicable" ) ]
1524
+ #[ multipart_suggestion( label = "remove parentheses surrounding the pattern" , applicability = "machine-applicable" ) ]
1531
1525
pub ( crate ) struct ParenthesesInMatchPatSugg {
1532
1526
#[ suggestion_part( code = "" ) ]
1533
1527
pub left : Span ,
@@ -1709,15 +1703,15 @@ impl AddToDiagnostic for FnTraitMissingParen {
1709
1703
rustc_errors:: SubdiagnosticMessage ,
1710
1704
) -> rustc_errors:: SubdiagnosticMessage ,
1711
1705
{
1712
- diag. span_label ( self . span , crate :: fluent_generated :: parse_fn_trait_missing_paren ) ;
1706
+ diag. span_label ( self . span , "`Fn` bounds require arguments in parentheses" ) ;
1713
1707
let applicability = if self . machine_applicable {
1714
1708
Applicability :: MachineApplicable
1715
1709
} else {
1716
1710
Applicability :: MaybeIncorrect
1717
1711
} ;
1718
1712
diag. span_suggestion_short (
1719
1713
self . span . shrink_to_hi ( ) ,
1720
- crate :: fluent_generated :: parse_add_paren ,
1714
+ "try adding parentheses" ,
1721
1715
"()" ,
1722
1716
applicability,
1723
1717
) ;
@@ -3467,7 +3461,7 @@ pub(crate) struct GenericArgsInPatRequireTurbofishSyntax {
3467
3461
}
3468
3462
3469
3463
#[ derive( Diagnostic ) ]
3470
- #[ diag( parse_transpose_dyn_or_impl ) ]
3464
+ #[ diag( "`for<...>` expected after `{$kw}`, not before" ) ]
3471
3465
pub ( crate ) struct TransposeDynOrImpl < ' a > {
3472
3466
#[ primary_span]
3473
3467
pub span : Span ,
@@ -3477,7 +3471,7 @@ pub(crate) struct TransposeDynOrImpl<'a> {
3477
3471
}
3478
3472
3479
3473
#[ derive( Subdiagnostic ) ]
3480
- #[ multipart_suggestion( parse_suggestion , applicability = "machine-applicable" ) ]
3474
+ #[ multipart_suggestion( label = "move `{$kw}` before the `for<...>`" , applicability = "machine-applicable" ) ]
3481
3475
pub ( crate ) struct TransposeDynOrImplSugg < ' a > {
3482
3476
#[ suggestion_part( code = "" ) ]
3483
3477
pub removal_span : Span ,
0 commit comments