about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/proc_macro_harness.rs
diff options
context:
space:
mode:
authorhe1pa <18012015693@163.com>2024-06-25 18:04:21 +0800
committerhe1pa <18012015693@163.com>2024-06-25 18:04:21 +0800
commita82f70eeee6d79fb4c3417da738279d3d7ff599a (patch)
tree50c030b8753a3934ae34bd69e9c33184c055a7f3 /compiler/rustc_builtin_macros/src/proc_macro_harness.rs
parent3d5d7a24f76006b391d8a53d903ae64c1b4a52d2 (diff)
downloadrust-a82f70eeee6d79fb4c3417da738279d3d7ff599a.tar.gz
rust-a82f70eeee6d79fb4c3417da738279d3d7ff599a.zip
Migrate some rustc_builtin_macros to SessionDiagnostic
Signed-off-by: he1pa <18012015693@163.com>
Diffstat (limited to 'compiler/rustc_builtin_macros/src/proc_macro_harness.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/proc_macro_harness.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs
index 99d0191958d..a8a595ea579 100644
--- a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs
+++ b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs
@@ -214,12 +214,12 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
         };
 
         if !is_fn {
-            let msg = format!(
-                "the `#[{}]` attribute may only be used on bare functions",
-                pprust::path_to_string(&attr.get_normal_item().path),
-            );
-
-            self.dcx.span_err(attr.span, msg);
+            self.dcx
+                .create_err(errors::AttributeOnlyBeUsedOnBareFunctions {
+                    span: attr.span,
+                    path: &pprust::path_to_string(&attr.get_normal_item().path),
+                })
+                .emit();
             return;
         }
 
@@ -228,12 +228,12 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
         }
 
         if !self.is_proc_macro_crate {
-            let msg = format!(
-                "the `#[{}]` attribute is only usable with crates of the `proc-macro` crate type",
-                pprust::path_to_string(&attr.get_normal_item().path),
-            );
-
-            self.dcx.span_err(attr.span, msg);
+            self.dcx
+                .create_err(errors::AttributeOnlyUsableWithCrateType {
+                    span: attr.span,
+                    path: &pprust::path_to_string(&attr.get_normal_item().path),
+                })
+                .emit();
             return;
         }