]> git.lizzy.rs Git - rust.git/blob - src/test/ui/feature-gates/feature-gate-untagged_unions.rs
Rollup merge of #93613 - crlf0710:rename_to_async_iter, r=yaahc
[rust.git] / src / test / ui / feature-gates / feature-gate-untagged_unions.rs
1 // ignore-tidy-linelength
2
3 union U1 { // OK
4     a: u8,
5 }
6
7 union U2<T: Copy> { // OK
8     a: T,
9 }
10
11 union U22<T> { // OK
12     a: std::mem::ManuallyDrop<T>,
13 }
14
15 union U3 {
16     a: String, //~ ERROR unions cannot contain fields that may need dropping
17 }
18
19 union U32 { // field that does not drop but is not `Copy`, either -- this is the real feature gate test!
20     a: std::cell::RefCell<i32>, //~ ERROR unions with non-`Copy` fields other than `ManuallyDrop<T>` are unstable
21 }
22
23 union U4<T> {
24     a: T, //~ ERROR unions cannot contain fields that may need dropping
25 }
26
27 union U5 { // Having a drop impl is OK
28     a: u8,
29 }
30
31 impl Drop for U5 {
32     fn drop(&mut self) {}
33 }
34
35 fn main() {}