2016-08-26 08:54:58 -05:00
|
|
|
#![feature(untagged_unions)]
|
|
|
|
|
|
|
|
// Non-copy
|
|
|
|
struct A;
|
|
|
|
struct B;
|
|
|
|
|
|
|
|
union U {
|
|
|
|
a: A,
|
|
|
|
b: B,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
unsafe {
|
|
|
|
{
|
|
|
|
let mut u = U { a: A };
|
|
|
|
let a = u.a;
|
2019-04-22 02:40:08 -05:00
|
|
|
let a = u.a; //~ ERROR use of moved value: `u`
|
2016-08-26 08:54:58 -05:00
|
|
|
}
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|