2016-08-22 16:56:14 +00:00
|
|
|
mod m {
|
|
|
|
pub union U {
|
2016-08-26 16:23:42 +00:00
|
|
|
pub a: u8,
|
|
|
|
pub(super) b: u8,
|
|
|
|
c: u8,
|
2016-08-22 16:56:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-16 18:19:24 +00:00
|
|
|
fn main() { unsafe {
|
2016-08-26 16:23:42 +00:00
|
|
|
let u = m::U { a: 0 }; // OK
|
|
|
|
let u = m::U { b: 0 }; // OK
|
2020-09-02 07:40:56 +00:00
|
|
|
let u = m::U { c: 0 }; //~ ERROR field `c` of union `U` is private
|
2016-08-26 16:23:42 +00:00
|
|
|
|
|
|
|
let m::U { a } = u; // OK
|
|
|
|
let m::U { b } = u; // OK
|
2020-09-02 07:40:56 +00:00
|
|
|
let m::U { c } = u; //~ ERROR field `c` of union `U` is private
|
2017-04-16 18:19:24 +00:00
|
|
|
}}
|