]> git.lizzy.rs Git - rust.git/blob - src/test/ui/union/union-with-drop-fields.rs
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup
[rust.git] / src / test / ui / union / union-with-drop-fields.rs
1 #![feature(untagged_unions)]
2 #![allow(dead_code)]
3
4 union U {
5     a: u8, // OK
6 }
7
8 union W {
9     a: String, //~ ERROR unions may not contain fields that need dropping
10     b: String, // OK, only one field is reported
11 }
12
13 struct S(String);
14
15 // `S` doesn't implement `Drop` trait, but still has non-trivial destructor
16 union Y {
17     a: S, //~ ERROR unions may not contain fields that need dropping
18 }
19
20 // We don't know if `T` is trivially-destructable or not until trans
21 union J<T> {
22     a: T, //~ ERROR unions may not contain fields that need dropping
23 }
24
25 union H<T: Copy> {
26     a: T, // OK, `T` is `Copy`, no destructor
27 }
28
29 fn main() {}