2018-04-27 23:32:00 -05:00
|
|
|
#![feature(decl_macro)]
|
2017-03-24 21:37:55 -05:00
|
|
|
|
|
|
|
mod foo {
|
|
|
|
struct S { x: u32 }
|
|
|
|
struct T(u32);
|
|
|
|
|
|
|
|
pub macro m($S:ident, $x:ident) {{
|
|
|
|
struct $S {
|
|
|
|
$x: u32,
|
|
|
|
x: i32,
|
|
|
|
}
|
|
|
|
|
2017-04-22 14:46:34 -05:00
|
|
|
let s = S { x: 0 }; //~ ERROR type `foo::S` is private
|
|
|
|
let _ = s.x; //~ ERROR type `foo::S` is private
|
2017-03-24 21:37:55 -05:00
|
|
|
|
2020-09-02 02:40:56 -05:00
|
|
|
let t = T(0); //~ ERROR type `T` is private
|
|
|
|
let _ = t.0; //~ ERROR type `T` is private
|
2017-03-24 21:37:55 -05:00
|
|
|
|
|
|
|
let s = $S { $x: 0, x: 1 };
|
|
|
|
assert_eq!((s.$x, s.x), (0, 1));
|
|
|
|
s
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let s = foo::m!(S, x);
|
|
|
|
assert_eq!(s.x, 0);
|
|
|
|
}
|