about summary refs log tree commit diff
path: root/compiler/rustc_macros/src
diff options
context:
space:
mode:
authorXiretza <xiretza@xiretza.xyz>2022-09-14 20:12:22 +0200
committerXiretza <xiretza@xiretza.xyz>2022-09-27 20:29:18 +0200
commit4d02892acfdb43490db815010d718bd324f853ad (patch)
tree3fa634e75b6bfefb1492fb49f33aa6f1f50967cf /compiler/rustc_macros/src
parent8489a67f0b0ca5a973d48b27d609c91cb93cf343 (diff)
downloadrust-4d02892acfdb43490db815010d718bd324f853ad.tar.gz
rust-4d02892acfdb43490db815010d718bd324f853ad.zip
Allow raw identifiers to be used as fluent arguments
Diffstat (limited to 'compiler/rustc_macros/src')
-rw-r--r--compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs2
-rw-r--r--compiler/rustc_macros/src/diagnostics/subdiagnostic.rs3
2 files changed, 5 insertions, 0 deletions
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),