From 28b29db8f02302997ff161cd97af766fa601aab1 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Wed, 17 Aug 2022 12:12:59 +0200 Subject: [PATCH] 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` --- compiler/rustc_macros/src/diagnostics/fluent.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_macros/src/diagnostics/fluent.rs b/compiler/rustc_macros/src/diagnostics/fluent.rs index a222b9d5f129..f7d8b494ee25 100644 --- a/compiler/rustc_macros/src/diagnostics/fluent.rs +++ b/compiler/rustc_macros/src/diagnostics/fluent.rs @@ -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), )