about summary refs log tree commit diff
path: root/tests/ui/parser/macro/macro-attr-bad.rs
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2025-07-06 15:15:01 -0700
committerJosh Triplett <josh@joshtriplett.org>2025-08-08 11:00:54 -0700
commitbad0d45b2dc2b2be36e9e82604a6c3dd95dba08a (patch)
tree161e336b95a92df8aabd2da30d516c7a0527f5e5 /tests/ui/parser/macro/macro-attr-bad.rs
parent2054a0c56b063c195d316e4ff44d0c9f8ad2c012 (diff)
downloadrust-bad0d45b2dc2b2be36e9e82604a6c3dd95dba08a.tar.gz
rust-bad0d45b2dc2b2be36e9e82604a6c3dd95dba08a.zip
mbe: Parse macro attribute rules
This handles various kinds of errors, but does not allow applying the
attributes yet.

This adds the feature gate `macro_attr`.
Diffstat (limited to 'tests/ui/parser/macro/macro-attr-bad.rs')
-rw-r--r--tests/ui/parser/macro/macro-attr-bad.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/parser/macro/macro-attr-bad.rs b/tests/ui/parser/macro/macro-attr-bad.rs
new file mode 100644
index 00000000000..4313a4d04ab
--- /dev/null
+++ b/tests/ui/parser/macro/macro-attr-bad.rs
@@ -0,0 +1,32 @@
+#![crate_type = "lib"]
+#![feature(macro_attr)]
+
+macro_rules! attr_incomplete_1 { attr }
+//~^ ERROR macro definition ended unexpectedly
+
+macro_rules! attr_incomplete_2 { attr() }
+//~^ ERROR macro definition ended unexpectedly
+
+macro_rules! attr_incomplete_3 { attr() {} }
+//~^ ERROR expected `=>`
+
+macro_rules! attr_incomplete_4 { attr() {} => }
+//~^ ERROR macro definition ended unexpectedly
+
+macro_rules! attr_noparens_1 { attr{} {} => {} }
+//~^ ERROR macro attribute argument matchers require parentheses
+
+macro_rules! attr_noparens_2 { attr[] {} => {} }
+//~^ ERROR macro attribute argument matchers require parentheses
+
+macro_rules! attr_noparens_3 { attr _ {} => {} }
+//~^ ERROR invalid macro matcher
+
+macro_rules! attr_dup_matcher_1 { attr() {$x:ident $x:ident} => {} }
+//~^ ERROR duplicate matcher binding
+
+macro_rules! attr_dup_matcher_2 { attr($x:ident $x:ident) {} => {} }
+//~^ ERROR duplicate matcher binding
+
+macro_rules! attr_dup_matcher_3 { attr($x:ident) {$x:ident} => {} }
+//~^ ERROR duplicate matcher binding