Skip to content

Commit c9f8439

Browse files
committed
remove messages.ftl from parser
1 parent 670d1a1 commit c9f8439

File tree

7 files changed

+55
-960
lines changed

7 files changed

+55
-960
lines changed

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
126126
rustc_mir_dataflow::DEFAULT_LOCALE_RESOURCE,
127127
rustc_mir_transform::DEFAULT_LOCALE_RESOURCE,
128128
rustc_monomorphize::DEFAULT_LOCALE_RESOURCE,
129-
rustc_parse::DEFAULT_LOCALE_RESOURCE,
130129
rustc_passes::DEFAULT_LOCALE_RESOURCE,
131130
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
132131
rustc_privacy::DEFAULT_LOCALE_RESOURCE,

compiler/rustc_parse/messages.ftl

Lines changed: 0 additions & 874 deletions
This file was deleted.

compiler/rustc_parse/src/errors.rs

Lines changed: 32 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
1414
use rustc_span::symbol::Ident;
1515
use rustc_span::{Span, Symbol};
1616

17-
use crate::fluent_generated as fluent;
1817
use 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")]
15251513
pub(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")]
15341522
pub(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")]
30683049
pub(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")]
31063078
pub(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")]
34713443
pub(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")]
34813453
pub(crate) struct TransposeDynOrImplSugg<'a> {
34823454
#[suggestion_part(code = "")]
34833455
pub removal_span: Span,

compiler/rustc_parse/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use rustc_data_structures::sync::Lrc;
2222
use rustc_errors::{Diagnostic, FatalError, Level, PResult};
2323
use rustc_session::parse::ParseSess;
2424
use rustc_span::{FileName, SourceFile, Span};
25-
2625
use std::path::Path;
2726

2827
pub const MACRO_ARGUMENTS: Option<&str> = Some("macro arguments");
@@ -35,8 +34,6 @@ pub mod validate_attr;
3534

3635
mod errors;
3736

38-
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
39-
4037
// A bunch of utility functions of the form `parse_<thing>_from_<source>`
4138
// where <thing> includes crate, expr, item, stmt, tts, and one that
4239
// uses a HOF to parse anything, and <source> includes file and

compiler/rustc_parse/src/parser/attr.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use crate::errors::{InvalidMetaItem, SuffixedLiteralInAttribute};
2-
use crate::fluent_generated as fluent;
3-
41
use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle};
2+
use crate::errors::{InvalidMetaItem, SuffixedLiteralInAttribute};
53
use rustc_ast as ast;
64
use rustc_ast::attr;
75
use rustc_ast::token::{self, Delimiter, Nonterminal};
@@ -57,9 +55,10 @@ impl<'a> Parser<'a> {
5755
let span = self.token.span;
5856
let mut err = self.dcx().struct_span_err_with_code(
5957
span,
60-
fluent::parse_inner_doc_comment_not_permitted,
58+
"expected outer doc comment",
6159
error_code!(E0753),
6260
);
61+
err.set_arg("item_type", "doc comment");
6362
if let Some(replacement_span) = self.annotate_following_item_if_applicable(
6463
&mut err,
6564
span,
@@ -68,10 +67,10 @@ impl<'a> Parser<'a> {
6867
token::CommentKind::Block => OuterAttributeType::DocBlockComment,
6968
},
7069
) {
71-
err.note(fluent::parse_note);
70+
err.note("inner doc comments like this (starting with `//!` or `/*!`) can only appear before items");
7271
err.span_suggestion_verbose(
7372
replacement_span,
74-
fluent::parse_suggestion,
73+
"you might have meant to write a regular comment",
7574
"",
7675
rustc_errors::Applicability::MachineApplicable,
7776
);
@@ -175,10 +174,10 @@ impl<'a> Parser<'a> {
175174
Ok(Some(item)) => {
176175
// FIXME(#100717)
177176
err.set_arg("item", item.kind.descr());
178-
err.span_label(item.span, fluent::parse_label_does_not_annotate_this);
177+
err.span_label(item.span, "the inner {$item_type} doesn't annotate this {$item}");
179178
err.span_suggestion_verbose(
180179
replacement_span,
181-
fluent::parse_sugg_change_inner_to_outer,
180+
"to annotate the {$item}, change the {$item_type} from inner to outer style",
182181
match attr_type {
183182
OuterAttributeType::Attribute => "",
184183
OuterAttributeType::DocBlockComment => "*",
@@ -202,27 +201,29 @@ impl<'a> Parser<'a> {
202201
Some(InnerAttrForbiddenReason::AfterOuterDocComment { prev_doc_comment_span }) => {
203202
let mut diag = self.dcx().struct_span_err(
204203
attr_sp,
205-
fluent::parse_inner_attr_not_permitted_after_outer_doc_comment,
204+
"an inner attribute is not permitted following an outer doc comment",
206205
);
207-
diag.span_label(attr_sp, fluent::parse_label_attr)
208-
.span_label(prev_doc_comment_span, fluent::parse_label_prev_doc_comment);
206+
diag.span_label(attr_sp, "not permitted following an outer doc comment")
207+
.span_label(prev_doc_comment_span, "previous doc comment");
209208
diag
210209
}
211210
Some(InnerAttrForbiddenReason::AfterOuterAttribute { prev_outer_attr_sp }) => {
212211
let mut diag = self.dcx().struct_span_err(
213212
attr_sp,
214-
fluent::parse_inner_attr_not_permitted_after_outer_attr,
213+
"an inner attribute is not permitted following an outer attribute",
215214
);
216-
diag.span_label(attr_sp, fluent::parse_label_attr)
217-
.span_label(prev_outer_attr_sp, fluent::parse_label_prev_attr);
215+
diag.span_label(attr_sp, "not permitted following an outer attribute")
216+
.span_label(prev_outer_attr_sp, "previous outer attribute");
218217
diag
219218
}
220-
Some(InnerAttrForbiddenReason::InCodeBlock) | None => {
221-
self.dcx().struct_span_err(attr_sp, fluent::parse_inner_attr_not_permitted)
222-
}
219+
Some(InnerAttrForbiddenReason::InCodeBlock) | None => self.struct_span_err(
220+
attr_sp,
221+
"an inner attribute is not permitted in this context",
222+
),
223223
};
224224

225-
diag.note(fluent::parse_inner_attr_explanation);
225+
diag.set_arg("item_type", "attribute");
226+
diag.note("inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files");
226227
if self
227228
.annotate_following_item_if_applicable(
228229
&mut diag,
@@ -231,7 +232,7 @@ impl<'a> Parser<'a> {
231232
)
232233
.is_some()
233234
{
234-
diag.note(fluent::parse_outer_attr_explanation);
235+
diag.note("outer attributes, like `#[test]`, annotate the item following them");
235236
};
236237
diag.emit();
237238
}

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use crate::errors::{
1818
UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration,
1919
UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead, WrapType,
2020
};
21-
use crate::fluent_generated as fluent;
2221
use crate::parser;
2322
use crate::parser::attr::InnerAttrPolicy;
2423
use rustc_ast as ast;
@@ -1212,7 +1211,7 @@ impl<'a> Parser<'a> {
12121211
if self.eat(&token::Gt) {
12131212
e.span_suggestion_verbose(
12141213
binop.span.shrink_to_lo(),
1215-
fluent::parse_sugg_turbofish_syntax,
1214+
"use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
12161215
"::",
12171216
Applicability::MaybeIncorrect,
12181217
)

compiler/rustc_parse/src/parser/item.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
33
use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, TrailingToken};
44
use crate::errors::{self, MacroExpandsToAdtField};
55
use crate::fluent_generated as fluent;
6+
use ast::StaticItem;
67
use rustc_ast::ast::*;
78
use rustc_ast::ptr::P;
89
use rustc_ast::token::{self, Delimiter, TokenKind};
@@ -1455,7 +1456,7 @@ impl<'a> Parser<'a> {
14551456

14561457
if this.token == token::Not {
14571458
if let Err(mut err) = this.unexpected::<()>() {
1458-
err.note(fluent::parse_macro_expands_to_enum_variant).emit();
1459+
err.note("macros cannot expand to enum variants").emit();
14591460
}
14601461

14611462
this.bump();

0 commit comments

Comments
 (0)