rust/tests/ui/hygiene/fields.rs

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

31 lines
624 B
Rust
Raw Normal View History

2017-05-25 02:04:03 +00:00
// ignore-pretty pretty-printing is unhygienic
#![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
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);
}