]>
Commit | Line | Data |
---|---|---|
136023e0 XL |
1 | // revisions: mirunsafeck thirunsafeck |
2 | // [thirunsafeck]compile-flags: -Z thir-unsafeck | |
3 | ||
9e0c209e | 4 | #![allow(dead_code)] |
9e0c209e SL |
5 | |
6 | union U { | |
7 | a: u8, // OK | |
8 | } | |
9 | ||
10 | union W { | |
5099ac24 | 11 | a: String, //~ ERROR unions cannot contain fields that may need dropping |
9e0c209e SL |
12 | b: String, // OK, only one field is reported |
13 | } | |
14 | ||
15 | struct S(String); | |
16 | ||
17 | // `S` doesn't implement `Drop` trait, but still has non-trivial destructor | |
18 | union Y { | |
5099ac24 | 19 | a: S, //~ ERROR unions cannot contain fields that may need dropping |
9e0c209e SL |
20 | } |
21 | ||
22 | // We don't know if `T` is trivially-destructable or not until trans | |
23 | union J<T> { | |
5099ac24 | 24 | a: T, //~ ERROR unions cannot contain fields that may need dropping |
9e0c209e SL |
25 | } |
26 | ||
27 | union H<T: Copy> { | |
28 | a: T, // OK, `T` is `Copy`, no destructor | |
29 | } | |
30 | ||
31 | fn main() {} |