2019-07-02 16:30:28 -05:00
|
|
|
// build-pass (FIXME(62277): could be check-pass?)
|
2018-11-05 07:35:30 -06:00
|
|
|
|
|
|
|
#![feature(untagged_unions)]
|
|
|
|
|
|
|
|
struct A;
|
|
|
|
struct B;
|
|
|
|
|
|
|
|
union U {
|
|
|
|
a: A,
|
|
|
|
b: B,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
unsafe {
|
|
|
|
{
|
|
|
|
let mut u = U { a: A };
|
|
|
|
let a = u.a;
|
|
|
|
u.a = A;
|
|
|
|
let a = u.a; // OK
|
|
|
|
}
|
|
|
|
{
|
|
|
|
let mut u = U { a: A };
|
|
|
|
let a = u.a;
|
|
|
|
u.b = B;
|
|
|
|
let a = u.a; // OK
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|