From 18388c9f7372d00fa958a421b3eec639a5b7b5a2 Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Fri, 7 Apr 2023 08:14:48 +0100 Subject: Rewrite added diagnostics as translatable Start messages with lowercase --- compiler/rustc_resolve/src/errors.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'compiler/rustc_resolve/src/errors.rs') diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index 867363f4246..ff44ccb265a 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -472,3 +472,30 @@ pub(crate) struct Indeterminate(#[primary_span] pub(crate) Span); #[derive(Diagnostic)] #[diag(resolve_module_only)] pub(crate) struct ModuleOnly(#[primary_span] pub(crate) Span); + +#[derive(Diagnostic, Default)] +#[diag(resolve_macro_expected_found)] +pub(crate) struct MacroExpectedFound<'a> { + #[primary_span] + pub(crate) span: Span, + pub(crate) found: &'a str, + pub(crate) expected: &'a str, + pub(crate) macro_path: &'a str, + #[subdiagnostic] + pub(crate) remove_surrounding_derive: Option, + #[subdiagnostic] + pub(crate) remove_surrounding_derive_help: Option>, +} + +#[derive(Subdiagnostic)] +#[help(resolve_remove_surrounding_derive)] +pub(crate) struct RemoveSurroundingDerive { + #[primary_span] + pub(crate) span: Span, +} + +#[derive(Subdiagnostic)] +#[help(resolve_add_as_non_derive)] +pub(crate) struct RemoveAddAsNonDerive<'a> { + pub(crate) macro_path: &'a str, +} -- cgit 1.4.1-3-g733a5 From 668a62984ac51a09987c5b1a7c1589814f7a95d4 Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Fri, 7 Apr 2023 08:44:19 +0100 Subject: Change type and field name to be clearer --- compiler/rustc_resolve/src/errors.rs | 4 ++-- compiler/rustc_resolve/src/macros.rs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_resolve/src/errors.rs') diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index ff44ccb265a..660614d3421 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -484,7 +484,7 @@ pub(crate) struct MacroExpectedFound<'a> { #[subdiagnostic] pub(crate) remove_surrounding_derive: Option, #[subdiagnostic] - pub(crate) remove_surrounding_derive_help: Option>, + pub(crate) add_as_non_derive: Option>, } #[derive(Subdiagnostic)] @@ -496,6 +496,6 @@ pub(crate) struct RemoveSurroundingDerive { #[derive(Subdiagnostic)] #[help(resolve_add_as_non_derive)] -pub(crate) struct RemoveAddAsNonDerive<'a> { +pub(crate) struct AddAsNonDerive<'a> { pub(crate) macro_path: &'a str, } diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index b2e23721295..22b014c0651 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -1,7 +1,7 @@ //! A bunch of methods and structures more or less related to resolving macros and //! interface provided by `Resolver` to macro expander. -use crate::errors::{MacroExpectedFound, RemoveAddAsNonDerive, RemoveSurroundingDerive}; +use crate::errors::{AddAsNonDerive, MacroExpectedFound, RemoveSurroundingDerive}; use crate::Namespace::*; use crate::{BuiltinMacroState, Determinacy}; use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet}; @@ -559,8 +559,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { && ext.macro_kind() != MacroKind::Derive { err.remove_surrounding_derive = Some(RemoveSurroundingDerive { span: path.span }); - err.remove_surrounding_derive_help = - Some(RemoveAddAsNonDerive { macro_path: &path_str }); + err.add_as_non_derive = Some(AddAsNonDerive { macro_path: &path_str }); } let mut err = self.tcx.sess.create_err(err); -- cgit 1.4.1-3-g733a5