diff options
| author | Josh Triplett <josh@joshtriplett.org> | 2025-07-28 15:28:20 -0700 |
|---|---|---|
| committer | Josh Triplett <josh@joshtriplett.org> | 2025-08-08 11:01:12 -0700 |
| commit | 489734cd08599df822c87d27a38f972413dc13ab (patch) | |
| tree | 50a7283ab3fcccf45838197745b3684c7cadc85f | |
| parent | 9a9ccc0edbf50428d0f12441cf50f32d5ea0f558 (diff) | |
| download | rust-489734cd08599df822c87d27a38f972413dc13ab.tar.gz rust-489734cd08599df822c87d27a38f972413dc13ab.zip | |
mbe: Add a test confirming that a macro attribute can apply itself recursively
This allows a macro attribute to implement default arguments by reapplying itself with the defaults filled in, for instance.
| -rw-r--r-- | tests/ui/macros/macro-rules-attr-nested.rs | 24 | ||||
| -rw-r--r-- | tests/ui/macros/macro-rules-attr-nested.run.stdout | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/macros/macro-rules-attr-nested.rs b/tests/ui/macros/macro-rules-attr-nested.rs new file mode 100644 index 00000000000..af5c30f00dd --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-nested.rs @@ -0,0 +1,24 @@ +//@ run-pass +//@ check-run-results +#![feature(macro_attr)] + +macro_rules! nest { + attr() { struct $name:ident; } => { + println!("nest"); + #[nest(1)] + struct $name; + }; + attr(1) { struct $name:ident; } => { + println!("nest(1)"); + #[nest(2)] + struct $name; + }; + attr(2) { struct $name:ident; } => { + println!("nest(2)"); + }; +} + +fn main() { + #[nest] + struct S; +} diff --git a/tests/ui/macros/macro-rules-attr-nested.run.stdout b/tests/ui/macros/macro-rules-attr-nested.run.stdout new file mode 100644 index 00000000000..46017f9ae08 --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-nested.run.stdout @@ -0,0 +1,3 @@ +nest +nest(1) +nest(2) |
