2017-05-25 02:04:03 +00:00
|
|
|
// ignore-pretty pretty-printing is unhygienic
|
|
|
|
|
2018-04-28 04:32:00 +00:00
|
|
|
#![feature(decl_macro)]
|
2017-03-25 02:37:55 +00: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 19:46:34 +00:00
|
|
|
let s = S { x: 0 }; //~ ERROR type `foo::S` is private
|
|
|
|
let _ = s.x; //~ ERROR type `foo::S` is private
|
2017-03-25 02:37:55 +00:00
|
|
|
|
2020-09-02 07:40:56 +00:00
|
|
|
let t = T(0); //~ ERROR type `T` is private
|
|
|
|
let _ = t.0; //~ ERROR type `T` is private
|
2017-03-25 02:37:55 +00: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);
|
|
|
|
}
|