Skip to content

Commit bf3b14d

Browse files
committed
remove messages.ftl from parser
1 parent 4286151 commit bf3b14d

File tree

7 files changed

+39
-920
lines changed

7 files changed

+39
-920
lines changed

Diff for: compiler/rustc_driver_impl/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
129129
rustc_mir_dataflow::DEFAULT_LOCALE_RESOURCE,
130130
rustc_mir_transform::DEFAULT_LOCALE_RESOURCE,
131131
rustc_monomorphize::DEFAULT_LOCALE_RESOURCE,
132-
rustc_parse::DEFAULT_LOCALE_RESOURCE,
133132
rustc_passes::DEFAULT_LOCALE_RESOURCE,
134133
rustc_privacy::DEFAULT_LOCALE_RESOURCE,
135134
rustc_query_system::DEFAULT_LOCALE_RESOURCE,

Diff for: compiler/rustc_parse/messages.ftl

-868
This file was deleted.

Diff for: compiler/rustc_parse/src/errors.rs

+16-22
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)]
@@ -1206,16 +1205,18 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier {
12061205

12071206
let mut diag = handler.struct_diagnostic(match token_descr {
12081207
Some(TokenDescription::ReservedIdentifier) => {
1209-
fluent::parse_expected_identifier_found_reserved_identifier_str
1208+
"expected identifier, found reserved identifier `{$token}`"
12101209
}
1211-
Some(TokenDescription::Keyword) => fluent::parse_expected_identifier_found_keyword_str,
1210+
Some(TokenDescription::Keyword) => "expected identifier, found keyword `{$token}`",
12121211
Some(TokenDescription::ReservedKeyword) => {
1213-
fluent::parse_expected_identifier_found_reserved_keyword_str
1212+
"expected identifier, found reserved keyword `{$token}`"
12141213
}
1214+
12151215
Some(TokenDescription::DocComment) => {
1216-
fluent::parse_expected_identifier_found_doc_comment_str
1216+
"expected identifier, found doc comment `{$token}`"
12171217
}
1218-
None => fluent::parse_expected_identifier_found_str,
1218+
1219+
None => "expected identifier, found `{$token}`",
12191220
});
12201221
diag.set_span(self.span);
12211222
diag.set_arg("token", self.token);
@@ -1262,28 +1263,21 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedSemi {
12621263
let token_descr = TokenDescription::from_token(&self.token);
12631264

12641265
let mut diag = handler.struct_diagnostic(match token_descr {
1265-
Some(TokenDescription::ReservedIdentifier) => DiagnosticMessage::Str(Cow::from(
1266-
"expected `;`, found reserved identifier `{$token}`",
1267-
)),
1268-
Some(TokenDescription::Keyword) => {
1269-
DiagnosticMessage::Str(Cow::from("expected `;`, found keyword `{$token}`"))
1266+
Some(TokenDescription::ReservedIdentifier) => {
1267+
"expected `;`, found reserved identifier `{$token}`"
12701268
}
1269+
Some(TokenDescription::Keyword) => "expected `;`, found keyword `{$token}`",
12711270
Some(TokenDescription::ReservedKeyword) => {
1272-
DiagnosticMessage::Str(Cow::from("expected `;`, found reserved keyword `{$token}`"))
1273-
}
1274-
Some(TokenDescription::DocComment) => {
1275-
DiagnosticMessage::Str(Cow::from("expected `;`, found doc comment `{$token}`"))
1271+
"expected `;`, found reserved keyword `{$token}`"
12761272
}
1277-
None => DiagnosticMessage::Str(Cow::from("expected `;`, found `{$token}`")),
1273+
Some(TokenDescription::DocComment) => "expected `;`, found doc comment `{$token}`",
1274+
None => "expected `;`, found `{$token}`",
12781275
});
12791276
diag.set_span(self.span);
12801277
diag.set_arg("token", self.token);
12811278

12821279
if let Some(unexpected_token_label) = self.unexpected_token_label {
1283-
diag.span_label(
1284-
unexpected_token_label,
1285-
DiagnosticMessage::Str(Cow::from("unexpected token")),
1286-
);
1280+
diag.span_label(unexpected_token_label, "unexpected token");
12871281
}
12881282

12891283
self.sugg.add_to_diagnostic(&mut diag);
@@ -1652,15 +1646,15 @@ impl AddToDiagnostic for FnTraitMissingParen {
16521646
rustc_errors::SubdiagnosticMessage,
16531647
) -> rustc_errors::SubdiagnosticMessage,
16541648
{
1655-
diag.span_label(self.span, crate::fluent_generated::parse_fn_trait_missing_paren);
1649+
diag.span_label(self.span, "`Fn` bounds require arguments in parentheses");
16561650
let applicability = if self.machine_applicable {
16571651
Applicability::MachineApplicable
16581652
} else {
16591653
Applicability::MaybeIncorrect
16601654
};
16611655
diag.span_suggestion_short(
16621656
self.span.shrink_to_hi(),
1663-
crate::fluent_generated::parse_add_paren,
1657+
"try adding parentheses",
16641658
"()",
16651659
applicability,
16661660
);

Diff for: compiler/rustc_parse/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ use rustc_ast::{AttrItem, Attribute, MetaItem};
2020
use rustc_ast_pretty::pprust;
2121
use rustc_data_structures::sync::Lrc;
2222
use rustc_errors::{Diagnostic, FatalError, Level, PResult};
23-
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
24-
use rustc_fluent_macro::fluent_messages;
2523
use rustc_session::parse::ParseSess;
2624
use rustc_span::{FileName, SourceFile, Span};
27-
2825
use std::path::Path;
2926

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

3835
mod errors;
3936

40-
fluent_messages! { "../messages.ftl" }
41-
4237
// A bunch of utility functions of the form `parse_<thing>_from_<source>`
4338
// where <thing> includes crate, expr, item, stmt, tts, and one that
4439
// uses a HOF to parse anything, and <source> includes file and

Diff for: compiler/rustc_parse/src/parser/attr.rs

+20-19
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.sess.span_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
}

Diff for: compiler/rustc_parse/src/parser/diagnostics.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use crate::errors::{
1919
UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead, WrapType,
2020
};
2121

22-
use crate::fluent_generated as fluent;
2322
use crate::parser;
2423
use rustc_ast as ast;
2524
use rustc_ast::ptr::P;
@@ -1102,7 +1101,7 @@ impl<'a> Parser<'a> {
11021101
if self.eat(&token::Gt) {
11031102
e.span_suggestion_verbose(
11041103
binop.span.shrink_to_lo(),
1105-
fluent::parse_sugg_turbofish_syntax,
1104+
"use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments",
11061105
"::",
11071106
Applicability::MaybeIncorrect,
11081107
)
@@ -2743,7 +2742,7 @@ impl<'a> Parser<'a> {
27432742
let mut err = self.struct_span_err(comma_span, "unexpected `,` in pattern");
27442743
if let Ok(seq_snippet) = self.span_to_snippet(seq_span) {
27452744
if is_mac_invoc {
2746-
err.note(fluent::parse_macro_expands_to_match_arm);
2745+
err.note("macros cannot expand to match arms");
27472746
} else {
27482747
err.multipart_suggestion(
27492748
format!(

Diff for: compiler/rustc_parse/src/parser/item.rs

+1-2
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;
@@ -1464,7 +1463,7 @@ impl<'a> Parser<'a> {
14641463

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

14701469
this.bump();

0 commit comments

Comments
 (0)