Skip to content

Commit abf7f7b

Browse files
committed
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.
1 parent 7b6c6d6 commit abf7f7b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ run-pass
2+
//@ check-run-results
3+
#![feature(macro_attr)]
4+
5+
macro_rules! nest {
6+
attr() { struct $name:ident; } => {
7+
println!("nest");
8+
#[nest(1)]
9+
struct $name;
10+
};
11+
attr(1) { struct $name:ident; } => {
12+
println!("nest(1)");
13+
#[nest(2)]
14+
struct $name;
15+
};
16+
attr(2) { struct $name:ident; } => {
17+
println!("nest(2)");
18+
};
19+
}
20+
21+
fn main() {
22+
#[nest]
23+
struct S;
24+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nest
2+
nest(1)
3+
nest(2)

0 commit comments

Comments
 (0)