about summary refs log tree commit diff
diff options
context:
space:
mode:
authorclubby789 <jamie@hill-daniel.co.uk>2024-11-12 14:05:42 +0000
committerclubby789 <jamie@hill-daniel.co.uk>2024-11-12 14:05:42 +0000
commit8522140caafdec5c63308bbe9aa9f5ce5e6b1863 (patch)
treec3ce3b536987b939482d9f419febbe708fea2652
parent5700240affd222f69b8755e2ff5d4ccaae9e6cf9 (diff)
downloadrust-8522140caafdec5c63308bbe9aa9f5ce5e6b1863.tar.gz
rust-8522140caafdec5c63308bbe9aa9f5ce5e6b1863.zip
Add test for using macro_rules macro as attribute/derive
-rw-r--r--tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.rs9
-rw-r--r--tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr52
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.rs b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.rs
new file mode 100644
index 00000000000..a2e1398c61e
--- /dev/null
+++ b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.rs
@@ -0,0 +1,9 @@
+#![crate_type = "lib"]
+
+macro_rules! sample { () => {} }
+
+#[sample]           //~ ERROR cannot find attribute `sample` in this scope
+#[derive(sample)]   //~ ERROR cannot find derive macro `sample` in this scope
+                    //~| ERROR cannot find derive macro `sample` in this scope
+                    //~| ERROR cannot find derive macro `sample` in this scope
+pub struct S {}
diff --git a/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr
new file mode 100644
index 00000000000..fb7b649d32f
--- /dev/null
+++ b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr
@@ -0,0 +1,52 @@
+error: cannot find derive macro `sample` in this scope
+  --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:6:10
+   |
+LL | #[derive(sample)]
+   |          ^^^^^^ consider moving the definition of `sample` before this call
+   |
+note: a macro with the same name exists, but it appears later at here
+  --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:3:14
+   |
+LL | macro_rules! sample { () => {} }
+   |              ^^^^^^
+
+error: cannot find attribute `sample` in this scope
+  --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:5:3
+   |
+LL | #[sample]
+   |   ^^^^^^ consider moving the definition of `sample` before this call
+   |
+note: a macro with the same name exists, but it appears later at here
+  --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:3:14
+   |
+LL | macro_rules! sample { () => {} }
+   |              ^^^^^^
+
+error: cannot find derive macro `sample` in this scope
+  --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:6:10
+   |
+LL | #[derive(sample)]
+   |          ^^^^^^ consider moving the definition of `sample` before this call
+   |
+note: a macro with the same name exists, but it appears later at here
+  --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:3:14
+   |
+LL | macro_rules! sample { () => {} }
+   |              ^^^^^^
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: cannot find derive macro `sample` in this scope
+  --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:6:10
+   |
+LL | #[derive(sample)]
+   |          ^^^^^^ consider moving the definition of `sample` before this call
+   |
+note: a macro with the same name exists, but it appears later at here
+  --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:3:14
+   |
+LL | macro_rules! sample { () => {} }
+   |              ^^^^^^
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: aborting due to 4 previous errors
+