]> git.proxmox.com Git - rustc.git/blame - src/test/ui/union/union-with-drop-fields.rs
New upstream version 1.60.0+dfsg1
[rustc.git] / src / test / ui / union / union-with-drop-fields.rs
CommitLineData
136023e0
XL
1// revisions: mirunsafeck thirunsafeck
2// [thirunsafeck]compile-flags: -Z thir-unsafeck
3
9e0c209e 4#![allow(dead_code)]
9e0c209e
SL
5
6union U {
7 a: u8, // OK
8}
9
10union 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
15struct S(String);
16
17// `S` doesn't implement `Drop` trait, but still has non-trivial destructor
18union 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
23union J<T> {
5099ac24 24 a: T, //~ ERROR unions cannot contain fields that may need dropping
9e0c209e
SL
25}
26
27union H<T: Copy> {
28 a: T, // OK, `T` is `Copy`, no destructor
29}
30
31fn main() {}