From 4d02892acfdb43490db815010d718bd324f853ad Mon Sep 17 00:00:00 2001 From: Xiretza Date: Wed, 14 Sep 2022 20:12:22 +0200 Subject: Allow raw identifiers to be used as fluent arguments --- compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs | 2 ++ compiler/rustc_macros/src/diagnostics/subdiagnostic.rs | 3 +++ 2 files changed, 5 insertions(+) (limited to 'compiler/rustc_macros/src') diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs index 38bd986f76f..9e88dc7a913 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs @@ -281,6 +281,8 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> { if should_generate_set_arg(&field) { let diag = &self.parent.diag; let ident = field.ident.as_ref().unwrap(); + // strip `r#` prefix, if present + let ident = format_ident!("{}", ident); return quote! { #diag.set_arg( stringify!(#ident), diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index adb4902ebc1..9a2588513f0 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -189,6 +189,9 @@ impl<'a> SubdiagnosticDeriveBuilder<'a> { let diag = &self.diag; let ident = ast.ident.as_ref().unwrap(); + // strip `r#` prefix, if present + let ident = format_ident!("{}", ident); + quote! { #diag.set_arg( stringify!(#ident), -- cgit 1.4.1-3-g733a5