about summary refs log tree commit diff
path: root/tests/ui/parser/macro
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2023-11-27 00:50:51 +0100
committerNadrieril <nadrieril+git@gmail.com>2023-12-03 12:25:46 +0100
commit0bfebc6105ea882d7048057718b2e34d09a5d17e (patch)
treec03bc15ce9507bcb06d0c062738dd62f7514b55a /tests/ui/parser/macro
parent80bdcbf50a63845dd3cfeb05751ba3dcbd1025b8 (diff)
downloadrust-0bfebc6105ea882d7048057718b2e34d09a5d17e.tar.gz
rust-0bfebc6105ea882d7048057718b2e34d09a5d17e.zip
Detect attempts to expand a macro to a match arm again
Because a macro invocation can expand to a never pattern, we can't rule
out a `arm!(),` arm at parse time. Instead we detect that case at
expansion time, if the macro tries to output a pattern followed by `=>`.
Diffstat (limited to 'tests/ui/parser/macro')
-rw-r--r--tests/ui/parser/macro/macro-expand-to-match-arm.rs1
-rw-r--r--tests/ui/parser/macro/macro-expand-to-match-arm.stderr1
2 files changed, 2 insertions, 0 deletions
diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.rs b/tests/ui/parser/macro/macro-expand-to-match-arm.rs
index 972ca61cc84..98d2a27884f 100644
--- a/tests/ui/parser/macro/macro-expand-to-match-arm.rs
+++ b/tests/ui/parser/macro/macro-expand-to-match-arm.rs
@@ -3,6 +3,7 @@ macro_rules! arm {
         $pattern => $block
         //~^ ERROR macro expansion ignores token `=>` and any following
         //~| NOTE the usage of `arm!` is likely invalid in pattern context
+        //~| NOTE macros cannot expand to match arms
     };
 }
 
diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.stderr b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
index a62109c5050..f162f7dd47b 100644
--- a/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
+++ b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
@@ -8,6 +8,7 @@ LL |         arm!(None => {}),
    |         ---------------- caused by the macro expansion here
    |
    = note: the usage of `arm!` is likely invalid in pattern context
+   = note: macros cannot expand to match arms
 
 error: aborting due to 1 previous error