]>
Commit | Line | Data |
---|---|---|
9e0c209e SL |
1 | #![feature(untagged_unions)] |
2 | #![allow(dead_code)] | |
3 | #![deny(unions_with_drop_fields)] | |
4 | ||
5 | union U { | |
6 | a: u8, // OK | |
7 | } | |
8 | ||
9 | union W { | |
10 | a: String, //~ ERROR union contains a field with possibly non-trivial drop code | |
11 | b: String, // OK, only one field is reported | |
12 | } | |
13 | ||
14 | struct S(String); | |
15 | ||
16 | // `S` doesn't implement `Drop` trait, but still has non-trivial destructor | |
17 | union Y { | |
18 | a: S, //~ ERROR union contains a field with possibly non-trivial drop code | |
19 | } | |
20 | ||
21 | // We don't know if `T` is trivially-destructable or not until trans | |
22 | union J<T> { | |
23 | a: T, //~ ERROR union contains a field with possibly non-trivial drop code | |
24 | } | |
25 | ||
26 | union H<T: Copy> { | |
27 | a: T, // OK, `T` is `Copy`, no destructor | |
28 | } | |
29 | ||
30 | fn main() {} |