Skip to content

Commit 28b29db

Browse files
committed
fluent: point to path containing error instead of module name
Example error before: error: name `generic_does_not_live_long_enough` does not start with the crate name --> compiler/rustc_error_messages/src/lib.rs:33:17 | 33 | borrowck => "../locales/en-US/borrowck.ftl", | ^^^^^^^^ | = help: prepend `borrowck_` to the slug name: `borrowck_generic_does_not_live_long_enough` after: error: name `generic_does_not_live_long_enough` does not start with the crate name --> compiler/rustc_error_messages/src/lib.rs:33:17 | 33 | borrowck => "../locales/en-US/borrowck.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: prepend `borrowck_` to the slug name: `borrowck_generic_does_not_live_long_enough`
1 parent c9b1a58 commit 28b29db

File tree

1 file changed

+5
-5
lines changed
  • compiler/rustc_macros/src/diagnostics

1 file changed

+5
-5
lines changed

compiler/rustc_macros/src/diagnostics/fluent.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
187187
for entry in resource.entries() {
188188
let span = res.ident.span();
189189
if let Entry::Message(Message { id: Identifier { name }, attributes, .. }) = entry {
190-
let _ = previous_defns.entry(name.to_string()).or_insert(ident_span);
190+
let _ = previous_defns.entry(name.to_string()).or_insert(path_span);
191191

192192
if name.contains('-') {
193193
Diagnostic::spanned(
194-
ident_span,
194+
path_span,
195195
Level::Error,
196196
format!("name `{name}` contains a '-' character"),
197197
)
@@ -212,7 +212,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
212212
Some(rest) => Ident::new(rest, span),
213213
None => {
214214
Diagnostic::spanned(
215-
ident_span,
215+
path_span,
216216
Level::Error,
217217
format!("name `{name}` does not start with the crate name"),
218218
)
@@ -238,7 +238,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
238238

239239
if attr_name.contains('-') {
240240
Diagnostic::spanned(
241-
ident_span,
241+
path_span,
242242
Level::Error,
243243
format!("attribute `{attr_name}` contains a '-' character"),
244244
)
@@ -261,7 +261,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
261261
match e {
262262
FluentError::Overriding { kind, id } => {
263263
Diagnostic::spanned(
264-
ident_span,
264+
path_span,
265265
Level::Error,
266266
format!("overrides existing {}: `{}`", kind, id),
267267
)

0 commit comments

Comments
 (0)