about summary refs log tree commit diff
path: root/compiler/rustc_macros/src
diff options
context:
space:
mode:
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),