Skip to content

Commit 2e4da98

Browse files
committed
remove messages.ftl from parser
1 parent 621282b commit 2e4da98

File tree

7 files changed

+44
-934
lines changed

7 files changed

+44
-934
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_privacy::DEFAULT_LOCALE_RESOURCE,
132131
rustc_query_system::DEFAULT_LOCALE_RESOURCE,

compiler/rustc_parse/messages.ftl

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

compiler/rustc_parse/src/errors.rs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
1111
use rustc_span::symbol::Ident;
1212
use rustc_span::{Span, Symbol};
1313

14-
use crate::fluent_generated as fluent;
1514
use crate::parser::{ForbiddenLetReason, TokenDescription};
1615

1716
#[derive(Diagnostic)]
@@ -498,7 +497,7 @@ pub(crate) struct ExpectedExpressionFoundLet {
498497

499498
#[derive(Subdiagnostic, Clone, Copy)]
500499
#[multipart_suggestion(
501-
parse_maybe_missing_let,
500+
label = "you might have meant to continue the let-chain",
502501
applicability = "maybe-incorrect",
503502
style = "verbose"
504503
)]
@@ -509,7 +508,7 @@ pub(crate) struct MaybeMissingLet {
509508

510509
#[derive(Subdiagnostic, Clone, Copy)]
511510
#[multipart_suggestion(
512-
parse_maybe_comparison,
511+
label = "you might have meant to compare for equality",
513512
applicability = "maybe-incorrect",
514513
style = "verbose"
515514
)]
@@ -1247,16 +1246,18 @@ impl<'a> IntoDiagnostic<'a> for ExpectedIdentifier {
12471246

12481247
let mut diag = handler.struct_diagnostic(match token_descr {
12491248
Some(TokenDescription::ReservedIdentifier) => {
1250-
fluent::parse_expected_identifier_found_reserved_identifier_str
1249+
"expected identifier, found reserved identifier `{$token}`"
12511250
}
1252-
Some(TokenDescription::Keyword) => fluent::parse_expected_identifier_found_keyword_str,
1251+
Some(TokenDescription::Keyword) => "expected identifier, found keyword `{$token}`",
12531252
Some(TokenDescription::ReservedKeyword) => {
1254-
fluent::parse_expected_identifier_found_reserved_keyword_str
1253+
"expected identifier, found reserved keyword `{$token}`"
12551254
}
1255+
12561256
Some(TokenDescription::DocComment) => {
1257-
fluent::parse_expected_identifier_found_doc_comment_str
1257+
"expected identifier, found doc comment `{$token}`"
12581258
}
1259-
None => fluent::parse_expected_identifier_found_str,
1259+
1260+
None => "expected identifier, found `{$token}`",
12601261
});
12611262
diag.set_span(self.span);
12621263
diag.set_arg("token", self.token);
@@ -1303,28 +1304,21 @@ impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
13031304
let token_descr = TokenDescription::from_token(&self.token);
13041305

13051306
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}`"
13111309
}
1310+
Some(TokenDescription::Keyword) => "expected `;`, found keyword `{$token}`",
13121311
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}`"
13171313
}
1318-
None => DiagnosticMessage::Str(Cow::from("expected `;`, found `{$token}`")),
1314+
Some(TokenDescription::DocComment) => "expected `;`, found doc comment `{$token}`",
1315+
None => "expected `;`, found `{$token}`",
13191316
});
13201317
diag.set_span(self.span);
13211318
diag.set_arg("token", self.token);
13221319

13231320
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");
13281322
}
13291323

13301324
self.sugg.add_to_diagnostic(&mut diag);
@@ -1518,7 +1512,7 @@ pub(crate) struct ParenthesesInForHeadSugg {
15181512
}
15191513

15201514
#[derive(Diagnostic)]
1521-
#[diag(parse_unexpected_parentheses_in_match_arm_pattern)]
1515+
#[diag("unexpected parentheses surrounding `match` arm pattern")]
15221516
pub(crate) struct ParenthesesInMatchPat {
15231517
#[primary_span]
15241518
pub span: Vec<Span>,
@@ -1527,7 +1521,7 @@ pub(crate) struct ParenthesesInMatchPat {
15271521
}
15281522

15291523
#[derive(Subdiagnostic)]
1530-
#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")]
1524+
#[multipart_suggestion(label = "remove parentheses surrounding the pattern", applicability = "machine-applicable")]
15311525
pub(crate) struct ParenthesesInMatchPatSugg {
15321526
#[suggestion_part(code = "")]
15331527
pub left: Span,
@@ -1709,15 +1703,15 @@ impl AddToDiagnostic for FnTraitMissingParen {
17091703
rustc_errors::SubdiagnosticMessage,
17101704
) -> rustc_errors::SubdiagnosticMessage,
17111705
{
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");
17131707
let applicability = if self.machine_applicable {
17141708
Applicability::MachineApplicable
17151709
} else {
17161710
Applicability::MaybeIncorrect
17171711
};
17181712
diag.span_suggestion_short(
17191713
self.span.shrink_to_hi(),
1720-
crate::fluent_generated::parse_add_paren,
1714+
"try adding parentheses",
17211715
"()",
17221716
applicability,
17231717
);
@@ -3467,7 +3461,7 @@ pub(crate) struct GenericArgsInPatRequireTurbofishSyntax {
34673461
}
34683462

34693463
#[derive(Diagnostic)]
3470-
#[diag(parse_transpose_dyn_or_impl)]
3464+
#[diag("`for<...>` expected after `{$kw}`, not before")]
34713465
pub(crate) struct TransposeDynOrImpl<'a> {
34723466
#[primary_span]
34733467
pub span: Span,
@@ -3477,7 +3471,7 @@ pub(crate) struct TransposeDynOrImpl<'a> {
34773471
}
34783472

34793473
#[derive(Subdiagnostic)]
3480-
#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")]
3474+
#[multipart_suggestion(label = "move `{$kw}` before the `for<...>`", applicability = "machine-applicable")]
34813475
pub(crate) struct TransposeDynOrImplSugg<'a> {
34823476
#[suggestion_part(code = "")]
34833477
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};
@@ -58,9 +56,10 @@ impl<'a> Parser<'a> {
5856
let span = self.token.span;
5957
let mut err = self.diagnostic().struct_span_err_with_code(
6058
span,
61-
fluent::parse_inner_doc_comment_not_permitted,
59+
"expected outer doc comment",
6260
error_code!(E0753),
6361
);
62+
err.set_arg("item_type", "doc comment");
6463
if let Some(replacement_span) = self.annotate_following_item_if_applicable(
6564
&mut err,
6665
span,
@@ -69,10 +68,10 @@ impl<'a> Parser<'a> {
6968
token::CommentKind::Block => OuterAttributeType::DocBlockComment,
7069
},
7170
) {
72-
err.note(fluent::parse_note);
71+
err.note("inner doc comments like this (starting with `//!` or `/*!`) can only appear before items");
7372
err.span_suggestion_verbose(
7473
replacement_span,
75-
fluent::parse_suggestion,
74+
"you might have meant to write a regular comment",
7675
"",
7776
rustc_errors::Applicability::MachineApplicable,
7877
);
@@ -176,10 +175,10 @@ impl<'a> Parser<'a> {
176175
Ok(Some(item)) => {
177176
// FIXME(#100717)
178177
err.set_arg("item", item.kind.descr());
179-
err.span_label(item.span, fluent::parse_label_does_not_annotate_this);
178+
err.span_label(item.span, "the inner {$item_type} doesn't annotate this {$item}");
180179
err.span_suggestion_verbose(
181180
replacement_span,
182-
fluent::parse_sugg_change_inner_to_outer,
181+
"to annotate the {$item}, change the {$item_type} from inner to outer style",
183182
match attr_type {
184183
OuterAttributeType::Attribute => "",
185184
OuterAttributeType::DocBlockComment => "*",
@@ -203,27 +202,29 @@ impl<'a> Parser<'a> {
203202
Some(InnerAttrForbiddenReason::AfterOuterDocComment { prev_doc_comment_span }) => {
204203
let mut diag = self.struct_span_err(
205204
attr_sp,
206-
fluent::parse_inner_attr_not_permitted_after_outer_doc_comment,
205+
"an inner attribute is not permitted following an outer doc comment",
207206
);
208-
diag.span_label(attr_sp, fluent::parse_label_attr)
209-
.span_label(prev_doc_comment_span, fluent::parse_label_prev_doc_comment);
207+
diag.span_label(attr_sp, "not permitted following an outer doc comment")
208+
.span_label(prev_doc_comment_span, "previous doc comment");
210209
diag
211210
}
212211
Some(InnerAttrForbiddenReason::AfterOuterAttribute { prev_outer_attr_sp }) => {
213212
let mut diag = self.struct_span_err(
214213
attr_sp,
215-
fluent::parse_inner_attr_not_permitted_after_outer_attr,
214+
"an inner attribute is not permitted following an outer attribute",
216215
);
217-
diag.span_label(attr_sp, fluent::parse_label_attr)
218-
.span_label(prev_outer_attr_sp, fluent::parse_label_prev_attr);
216+
diag.span_label(attr_sp, "not permitted following an outer attribute")
217+
.span_label(prev_outer_attr_sp, "previous outer attribute");
219218
diag
220219
}
221-
Some(InnerAttrForbiddenReason::InCodeBlock) | None => {
222-
self.struct_span_err(attr_sp, fluent::parse_inner_attr_not_permitted)
223-
}
220+
Some(InnerAttrForbiddenReason::InCodeBlock) | None => self.struct_span_err(
221+
attr_sp,
222+
"an inner attribute is not permitted in this context",
223+
),
224224
};
225225

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

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
UnexpectedConstParamDeclaration, UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets,
1919
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;
@@ -1185,7 +1184,7 @@ impl<'a> Parser<'a> {
11851184
if self.eat(&token::Gt) {
11861185
e.span_suggestion_verbose(
11871186
binop.span.shrink_to_lo(),
1188-
fluent::parse_sugg_turbofish_syntax,
1187+
"use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
11891188
"::",
11901189
Applicability::MaybeIncorrect,
11911190
)

compiler/rustc_parse/src/parser/item.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::diagnostics::{dummy_arg, ConsumeClosingDelim};
22
use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
33
use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, TrailingToken};
44
use crate::errors::{self, MacroExpandsToAdtField};
5-
use crate::fluent_generated as fluent;
65
use ast::StaticItem;
76
use rustc_ast::ast::*;
87
use rustc_ast::ptr::P;
@@ -1463,7 +1462,7 @@ impl<'a> Parser<'a> {
14631462

14641463
if this.token == token::Not {
14651464
if let Err(mut err) = this.unexpected::<()>() {
1466-
err.note(fluent::parse_macro_expands_to_enum_variant).emit();
1465+
err.note("macros cannot expand to enum variants").emit();
14671466
}
14681467

14691468
this.bump();

0 commit comments

Comments
 (0)