mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
23 lines
320 B
Rust
23 lines
320 B
Rust
#![feature(decl_macro)]
|
|
|
|
macro modern($a: ident) {
|
|
struct Modern {
|
|
a: u8,
|
|
$a: u8, // OK
|
|
}
|
|
}
|
|
|
|
macro_rules! legacy {
|
|
($a: ident) => {
|
|
struct Legacy {
|
|
a: u8,
|
|
$a: u8, //~ ERROR field `a` is already declared
|
|
}
|
|
}
|
|
}
|
|
|
|
modern!(a);
|
|
legacy!(a);
|
|
|
|
fn main() {}
|