rust/tests/ui/privacy/union-field-privacy-1.rs

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

18 lines
385 B
Rust
Raw Normal View History

mod m {
pub union U {
pub a: u8,
pub(super) b: u8,
c: u8,
}
}
fn main() { unsafe {
let u = m::U { a: 0 }; // OK
let u = m::U { b: 0 }; // OK
let u = m::U { c: 0 }; //~ ERROR field `c` of union `U` is private
let m::U { a } = u; // OK
let m::U { b } = u; // OK
let m::U { c } = u; //~ ERROR field `c` of union `U` is private
}}