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`
This commit is contained in:
Xiretza 2022-08-17 12:12:59 +02:00
parent c9b1a5874d
commit 28b29db8f0

View File

@ -187,11 +187,11 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
for entry in resource.entries() {
let span = res.ident.span();
if let Entry::Message(Message { id: Identifier { name }, attributes, .. }) = entry {
let _ = previous_defns.entry(name.to_string()).or_insert(ident_span);
let _ = previous_defns.entry(name.to_string()).or_insert(path_span);
if name.contains('-') {
Diagnostic::spanned(
ident_span,
path_span,
Level::Error,
format!("name `{name}` contains a '-' character"),
)
@ -212,7 +212,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
Some(rest) => Ident::new(rest, span),
None => {
Diagnostic::spanned(
ident_span,
path_span,
Level::Error,
format!("name `{name}` does not start with the crate name"),
)
@ -238,7 +238,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
if attr_name.contains('-') {
Diagnostic::spanned(
ident_span,
path_span,
Level::Error,
format!("attribute `{attr_name}` contains a '-' character"),
)
@ -261,7 +261,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
match e {
FluentError::Overriding { kind, id } => {
Diagnostic::spanned(
ident_span,
path_span,
Level::Error,
format!("overrides existing {}: `{}`", kind, id),
)