@@ -14,7 +14,6 @@ use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
1414use rustc_span:: symbol:: Ident ;
1515use rustc_span:: { Span , Symbol } ;
1616
17- use crate :: fluent_generated as fluent;
1817use crate :: parser:: { ForbiddenLetReason , TokenDescription } ;
1918
2019#[ derive( Diagnostic ) ]
@@ -501,7 +500,7 @@ pub(crate) struct ExpectedExpressionFoundLet {
501500
502501#[ derive( Subdiagnostic , Clone , Copy ) ]
503502#[ multipart_suggestion(
504- parse_maybe_missing_let ,
503+ label = "you might have meant to continue the let-chain" ,
505504 applicability = "maybe-incorrect" ,
506505 style = "verbose"
507506) ]
@@ -512,7 +511,7 @@ pub(crate) struct MaybeMissingLet {
512511
513512#[ derive( Subdiagnostic , Clone , Copy ) ]
514513#[ multipart_suggestion(
515- parse_maybe_comparison ,
514+ label = "you might have meant to compare for equality" ,
516515 applicability = "maybe-incorrect" ,
517516 style = "verbose"
518517) ]
@@ -1245,25 +1244,21 @@ impl<'a> IntoDiagnostic<'a> for ExpectedIdentifier {
12451244 fn into_diagnostic ( self , dcx : & ' a DiagCtxt , level : Level ) -> DiagnosticBuilder < ' a > {
12461245 let token_descr = TokenDescription :: from_token ( & self . token ) ;
12471246
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+ } ) ;
12671262 diag. set_span ( self . span ) ;
12681263 diag. set_arg ( "token" , self . token ) ;
12691264
@@ -1306,28 +1301,21 @@ impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
13061301 let token_descr = TokenDescription :: from_token ( & self . token ) ;
13071302
13081303 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}`"
13141306 }
1307+ Some ( TokenDescription :: Keyword ) => "expected `;`, found keyword `{$token}`" ,
13151308 Some ( TokenDescription :: ReservedKeyword ) => {
1316- DiagnosticMessage :: Str ( Cow :: from ( "expected `;`, found reserved keyword `{$token}`" ) )
1309+ "expected `;`, found reserved keyword `{$token}`"
13171310 }
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}`" ,
13221313 } ) ;
13231314 diag. set_span ( self . span ) ;
13241315 diag. set_arg ( "token" , self . token ) ;
13251316
13261317 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" ) ;
13311319 }
13321320
13331321 self . sugg . add_to_diagnostic ( & mut diag) ;
@@ -1521,7 +1509,7 @@ pub(crate) struct ParenthesesInForHeadSugg {
15211509}
15221510
15231511#[ derive( Diagnostic ) ]
1524- #[ diag( parse_unexpected_parentheses_in_match_arm_pattern ) ]
1512+ #[ diag( "unexpected parentheses surrounding `match` arm pattern" ) ]
15251513pub ( crate ) struct ParenthesesInMatchPat {
15261514 #[ primary_span]
15271515 pub span : Vec < Span > ,
@@ -1530,7 +1518,7 @@ pub(crate) struct ParenthesesInMatchPat {
15301518}
15311519
15321520#[ derive( Subdiagnostic ) ]
1533- #[ multipart_suggestion( parse_suggestion , applicability = "machine-applicable" ) ]
1521+ #[ multipart_suggestion( label = "remove parentheses surrounding the pattern" , applicability = "machine-applicable" ) ]
15341522pub ( crate ) struct ParenthesesInMatchPatSugg {
15351523 #[ suggestion_part( code = "" ) ]
15361524 pub left : Span ,
@@ -1709,15 +1697,15 @@ impl AddToDiagnostic for FnTraitMissingParen {
17091697 where
17101698 F : Fn ( & mut rustc_errors:: Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
17111699 {
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" ) ;
17131701 let applicability = if self . machine_applicable {
17141702 Applicability :: MachineApplicable
17151703 } else {
17161704 Applicability :: MaybeIncorrect
17171705 } ;
17181706 diag. span_suggestion_short (
17191707 self . span . shrink_to_hi ( ) ,
1720- crate :: fluent_generated :: parse_add_paren ,
1708+ "try adding parentheses" ,
17211709 "()" ,
17221710 applicability,
17231711 ) ;
@@ -3057,18 +3045,11 @@ pub(crate) struct AssocLifetime {
30573045}
30583046
30593047#[ 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" ) ]
30683049pub ( crate ) struct ModifierLifetime {
30693050 #[ primary_span]
30703051 #[ suggestion(
3071- label = "remove the `{$sigil }`" ,
3052+ label = "remove the `{$modifier }`" ,
30723053 style = "tool-only" ,
30733054 applicability = "maybe-incorrect" ,
30743055 code = ""
@@ -3092,15 +3073,6 @@ pub(crate) struct ParenthesizedLifetime {
30923073 pub snippet : String ,
30933074}
30943075
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-
31043076#[ derive( Diagnostic ) ]
31053077#[ diag( "underscore literal suffix is not allowed" ) ]
31063078pub ( crate ) struct UnderscoreLiteralSuffix {
@@ -3467,7 +3439,7 @@ pub(crate) struct GenericArgsInPatRequireTurbofishSyntax {
34673439}
34683440
34693441#[ derive( Diagnostic ) ]
3470- #[ diag( parse_transpose_dyn_or_impl ) ]
3442+ #[ diag( "`for<...>` expected after `{$kw}`, not before" ) ]
34713443pub ( crate ) struct TransposeDynOrImpl < ' a > {
34723444 #[ primary_span]
34733445 pub span : Span ,
@@ -3477,7 +3449,7 @@ pub(crate) struct TransposeDynOrImpl<'a> {
34773449}
34783450
34793451#[ derive( Subdiagnostic ) ]
3480- #[ multipart_suggestion( parse_suggestion , applicability = "machine-applicable" ) ]
3452+ #[ multipart_suggestion( label = "move `{$kw}` before the `for<...>`" , applicability = "machine-applicable" ) ]
34813453pub ( crate ) struct TransposeDynOrImplSugg < ' a > {
34823454 #[ suggestion_part( code = "" ) ]
34833455 pub removal_span : Span ,
0 commit comments