@@ -14,7 +14,6 @@ use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
14
14
use rustc_span:: symbol:: Ident ;
15
15
use rustc_span:: { Span , Symbol } ;
16
16
17
- use crate :: fluent_generated as fluent;
18
17
use crate :: parser:: { ForbiddenLetReason , TokenDescription } ;
19
18
20
19
#[ derive( Diagnostic ) ]
@@ -501,7 +500,7 @@ pub(crate) struct ExpectedExpressionFoundLet {
501
500
502
501
#[ derive( Subdiagnostic , Clone , Copy ) ]
503
502
#[ multipart_suggestion(
504
- parse_maybe_missing_let ,
503
+ label = "you might have meant to continue the let-chain" ,
505
504
applicability = "maybe-incorrect" ,
506
505
style = "verbose"
507
506
) ]
@@ -512,7 +511,7 @@ pub(crate) struct MaybeMissingLet {
512
511
513
512
#[ derive( Subdiagnostic , Clone , Copy ) ]
514
513
#[ multipart_suggestion(
515
- parse_maybe_comparison ,
514
+ label = "you might have meant to compare for equality" ,
516
515
applicability = "maybe-incorrect" ,
517
516
style = "verbose"
518
517
) ]
@@ -1245,25 +1244,21 @@ impl<'a> IntoDiagnostic<'a> for ExpectedIdentifier {
1245
1244
fn into_diagnostic ( self , dcx : & ' a DiagCtxt , level : Level ) -> DiagnosticBuilder < ' a > {
1246
1245
let token_descr = TokenDescription :: from_token ( & self . token ) ;
1247
1246
1248
- let mut diag = DiagnosticBuilder :: new (
1249
- dcx,
1250
- level,
1251
- match token_descr {
1252
- Some ( TokenDescription :: ReservedIdentifier ) => {
1253
- fluent:: parse_expected_identifier_found_reserved_identifier_str
1254
- }
1255
- Some ( TokenDescription :: Keyword ) => {
1256
- fluent:: parse_expected_identifier_found_keyword_str
1257
- }
1258
- Some ( TokenDescription :: ReservedKeyword ) => {
1259
- fluent:: parse_expected_identifier_found_reserved_keyword_str
1260
- }
1261
- Some ( TokenDescription :: DocComment ) => {
1262
- fluent:: parse_expected_identifier_found_doc_comment_str
1263
- }
1264
- None => fluent:: parse_expected_identifier_found_str,
1265
- } ,
1266
- ) ;
1247
+ let mut diag = handler. struct_diagnostic ( match token_descr {
1248
+ Some ( TokenDescription :: ReservedIdentifier ) => {
1249
+ "expected identifier, found reserved identifier `{$token}`"
1250
+ }
1251
+ Some ( TokenDescription :: Keyword ) => "expected identifier, found keyword `{$token}`" ,
1252
+ Some ( TokenDescription :: ReservedKeyword ) => {
1253
+ "expected identifier, found reserved keyword `{$token}`"
1254
+ }
1255
+
1256
+ Some ( TokenDescription :: DocComment ) => {
1257
+ "expected identifier, found doc comment `{$token}`"
1258
+ }
1259
+
1260
+ None => "expected identifier, found `{$token}`" ,
1261
+ } ) ;
1267
1262
diag. set_span ( self . span ) ;
1268
1263
diag. set_arg ( "token" , self . token ) ;
1269
1264
@@ -1306,28 +1301,21 @@ impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
1306
1301
let token_descr = TokenDescription :: from_token ( & self . token ) ;
1307
1302
1308
1303
let mut diag = handler. struct_diagnostic ( match token_descr {
1309
- Some ( TokenDescription :: ReservedIdentifier ) => DiagnosticMessage :: Str ( Cow :: from (
1310
- "expected `;`, found reserved identifier `{$token}`" ,
1311
- ) ) ,
1312
- Some ( TokenDescription :: Keyword ) => {
1313
- DiagnosticMessage :: Str ( Cow :: from ( "expected `;`, found keyword `{$token}`" ) )
1304
+ Some ( TokenDescription :: ReservedIdentifier ) => {
1305
+ "expected `;`, found reserved identifier `{$token}`"
1314
1306
}
1307
+ Some ( TokenDescription :: Keyword ) => "expected `;`, found keyword `{$token}`" ,
1315
1308
Some ( TokenDescription :: ReservedKeyword ) => {
1316
- DiagnosticMessage :: Str ( Cow :: from ( "expected `;`, found reserved keyword `{$token}`" ) )
1309
+ "expected `;`, found reserved keyword `{$token}`"
1317
1310
}
1318
- Some ( TokenDescription :: DocComment ) => {
1319
- DiagnosticMessage :: Str ( Cow :: from ( "expected `;`, found doc comment `{$token}`" ) )
1320
- }
1321
- None => DiagnosticMessage :: Str ( Cow :: from ( "expected `;`, found `{$token}`" ) ) ,
1311
+ Some ( TokenDescription :: DocComment ) => "expected `;`, found doc comment `{$token}`" ,
1312
+ None => "expected `;`, found `{$token}`" ,
1322
1313
} ) ;
1323
1314
diag. set_span ( self . span ) ;
1324
1315
diag. set_arg ( "token" , self . token ) ;
1325
1316
1326
1317
if let Some ( unexpected_token_label) = self . unexpected_token_label {
1327
- diag. span_label (
1328
- unexpected_token_label,
1329
- DiagnosticMessage :: Str ( Cow :: from ( "unexpected token" ) ) ,
1330
- ) ;
1318
+ diag. span_label ( unexpected_token_label, "unexpected token" ) ;
1331
1319
}
1332
1320
1333
1321
self . sugg . add_to_diagnostic ( & mut diag) ;
@@ -1521,7 +1509,7 @@ pub(crate) struct ParenthesesInForHeadSugg {
1521
1509
}
1522
1510
1523
1511
#[ derive( Diagnostic ) ]
1524
- #[ diag( parse_unexpected_parentheses_in_match_arm_pattern ) ]
1512
+ #[ diag( "unexpected parentheses surrounding `match` arm pattern" ) ]
1525
1513
pub ( crate ) struct ParenthesesInMatchPat {
1526
1514
#[ primary_span]
1527
1515
pub span : Vec < Span > ,
@@ -1530,7 +1518,7 @@ pub(crate) struct ParenthesesInMatchPat {
1530
1518
}
1531
1519
1532
1520
#[ derive( Subdiagnostic ) ]
1533
- #[ multipart_suggestion( parse_suggestion , applicability = "machine-applicable" ) ]
1521
+ #[ multipart_suggestion( label = "remove parentheses surrounding the pattern" , applicability = "machine-applicable" ) ]
1534
1522
pub ( crate ) struct ParenthesesInMatchPatSugg {
1535
1523
#[ suggestion_part( code = "" ) ]
1536
1524
pub left : Span ,
@@ -1709,15 +1697,15 @@ impl AddToDiagnostic for FnTraitMissingParen {
1709
1697
where
1710
1698
F : Fn ( & mut rustc_errors:: Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
1711
1699
{
1712
- diag. span_label ( self . span , crate :: fluent_generated :: parse_fn_trait_missing_paren ) ;
1700
+ diag. span_label ( self . span , "`Fn` bounds require arguments in parentheses" ) ;
1713
1701
let applicability = if self . machine_applicable {
1714
1702
Applicability :: MachineApplicable
1715
1703
} else {
1716
1704
Applicability :: MaybeIncorrect
1717
1705
} ;
1718
1706
diag. span_suggestion_short (
1719
1707
self . span . shrink_to_hi ( ) ,
1720
- crate :: fluent_generated :: parse_add_paren ,
1708
+ "try adding parentheses" ,
1721
1709
"()" ,
1722
1710
applicability,
1723
1711
) ;
@@ -3057,18 +3045,11 @@ pub(crate) struct AssocLifetime {
3057
3045
}
3058
3046
3059
3047
#[ derive( Diagnostic ) ]
3060
- #[ diag( "`~const` may only modify trait bounds, not lifetime bounds" ) ]
3061
- pub ( crate ) struct TildeConstLifetime {
3062
- #[ primary_span]
3063
- pub span : Span ,
3064
- }
3065
-
3066
- #[ derive( Diagnostic ) ]
3067
- #[ diag( "`{$sigil}` may only modify trait bounds, not lifetime bounds" ) ]
3048
+ #[ diag( "`{$modifier}` may only modify trait bounds, not lifetime bounds" ) ]
3068
3049
pub ( crate ) struct ModifierLifetime {
3069
3050
#[ primary_span]
3070
3051
#[ suggestion(
3071
- label = "remove the `{$sigil }`" ,
3052
+ label = "remove the `{$modifier }`" ,
3072
3053
style = "tool-only" ,
3073
3054
applicability = "maybe-incorrect" ,
3074
3055
code = ""
@@ -3092,15 +3073,6 @@ pub(crate) struct ParenthesizedLifetime {
3092
3073
pub snippet : String ,
3093
3074
}
3094
3075
3095
- #[ derive( Diagnostic ) ]
3096
- #[ diag( "const bounds must start with `~`" ) ]
3097
- pub ( crate ) struct ConstMissingTilde {
3098
- #[ primary_span]
3099
- pub span : Span ,
3100
- #[ suggestion( label = "add `~`" , code = "~" , applicability = "machine-applicable" ) ]
3101
- pub start : Span ,
3102
- }
3103
-
3104
3076
#[ derive( Diagnostic ) ]
3105
3077
#[ diag( "underscore literal suffix is not allowed" ) ]
3106
3078
pub ( crate ) struct UnderscoreLiteralSuffix {
@@ -3467,7 +3439,7 @@ pub(crate) struct GenericArgsInPatRequireTurbofishSyntax {
3467
3439
}
3468
3440
3469
3441
#[ derive( Diagnostic ) ]
3470
- #[ diag( parse_transpose_dyn_or_impl ) ]
3442
+ #[ diag( "`for<...>` expected after `{$kw}`, not before" ) ]
3471
3443
pub ( crate ) struct TransposeDynOrImpl < ' a > {
3472
3444
#[ primary_span]
3473
3445
pub span : Span ,
@@ -3477,7 +3449,7 @@ pub(crate) struct TransposeDynOrImpl<'a> {
3477
3449
}
3478
3450
3479
3451
#[ derive( Subdiagnostic ) ]
3480
- #[ multipart_suggestion( parse_suggestion , applicability = "machine-applicable" ) ]
3452
+ #[ multipart_suggestion( label = "move `{$kw}` before the `for<...>`" , applicability = "machine-applicable" ) ]
3481
3453
pub ( crate ) struct TransposeDynOrImplSugg < ' a > {
3482
3454
#[ suggestion_part( code = "" ) ]
3483
3455
pub removal_span : Span ,
0 commit comments