]>
Commit | Line | Data |
---|---|---|
9e0c209e SL |
1 | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | #![feature(untagged_unions)] | |
12 | ||
13 | // Non-copy | |
14 | struct A; | |
15 | struct B; | |
16 | ||
17 | union U { | |
18 | a: A, | |
19 | b: B, | |
20 | } | |
21 | ||
22 | fn main() { | |
23 | unsafe { | |
24 | { | |
25 | let mut u = U { a: A }; | |
26 | let a = u.a; | |
27 | let a = u.a; //~ ERROR use of moved value: `u.a` | |
28 | } | |
29 | { | |
30 | let mut u = U { a: A }; | |
31 | let a = u.a; | |
32 | u.a = A; | |
33 | let a = u.a; // OK | |
34 | } | |
35 | { | |
36 | let mut u = U { a: A }; | |
37 | let a = u.a; | |
38 | u.b = B; | |
39 | let a = u.a; // OK | |
40 | } | |
41 | } | |
42 | } |