]> git.proxmox.com Git - rustc.git/blame - src/test/ui/union/field_checks.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / union / field_checks.rs
CommitLineData
064997fb
FG
1use std::mem::ManuallyDrop;
2
3union U1 { // OK
4 a: u8,
5}
6
7union U2<T: Copy> { // OK
8 a: T,
9}
10
11union U22<T> { // OK
12 a: ManuallyDrop<T>,
13}
14
15union U23<T> { // OK
16 a: (ManuallyDrop<T>, i32),
17}
18
19union U24<T> { // OK
20 a: [ManuallyDrop<T>; 2],
21}
22
23union U3 {
24 a: String, //~ ERROR unions cannot contain fields that may need dropping
25}
26
27union U32 { // field that does not drop but is not `Copy`, either
28 a: std::cell::RefCell<i32>, //~ ERROR unions cannot contain fields that may need dropping
29}
30
31union U4<T> {
32 a: T, //~ ERROR unions cannot contain fields that may need dropping
33}
34
35union U5 { // Having a drop impl is OK
36 a: u8,
37}
38
39impl Drop for U5 {
40 fn drop(&mut self) {}
41}
42
43union U5Nested { // a nested union that drops is NOT OK
44 nest: U5, //~ ERROR unions cannot contain fields that may need dropping
45}
46
47union U5Nested2 { // for now we don't special-case empty arrays
48 nest: [U5; 0], //~ ERROR unions cannot contain fields that may need dropping
49}
50
51union U6 { // OK
52 s: &'static i32,
53 m: &'static mut i32,
54}
55
56union U7<T> { // OK
57 f: (&'static mut i32, ManuallyDrop<T>, i32),
58}
59
60union U8<T> { // OK
61 f1: [(&'static mut i32, i32); 8],
62 f2: [ManuallyDrop<T>; 2],
63}
64
65fn main() {}