rust/tests/ui/hygiene/fields.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
576 B
Rust
Raw Normal View History

#![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
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);
}