mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-03 10:47:16 +00:00

This allows a macro attribute to implement default arguments by reapplying itself with the defaults filled in, for instance.
25 lines
432 B
Rust
25 lines
432 B
Rust
//@ 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;
|
|
}
|