]> git.lizzy.rs Git - rust.git/blob - tests/ui/union/union-derive-clone.rs
add (currently ICEing) test
[rust.git] / tests / ui / union / union-derive-clone.rs
1 // revisions: mirunsafeck thirunsafeck
2 // [thirunsafeck]compile-flags: -Z thir-unsafeck
3
4 use std::mem::ManuallyDrop;
5
6 #[derive(Clone)] //~ ERROR the trait bound `U1: Copy` is not satisfied
7 union U1 {
8     a: u8,
9 }
10
11 #[derive(Clone)]
12 union U2 {
13     a: u8, // OK
14 }
15
16 impl Copy for U2 {}
17
18 #[derive(Clone, Copy)]
19 union U3 {
20     a: u8, // OK
21 }
22
23 #[derive(Clone, Copy)]
24 union U4<T: Copy> {
25     a: T, // OK
26 }
27
28 #[derive(Clone, Copy)]
29 union U5<T> {
30     a: ManuallyDrop<T>, // OK
31 }
32
33 #[derive(Clone)]
34 struct CloneNoCopy;
35
36 fn main() {
37     let u = U5 { a: ManuallyDrop::new(CloneNoCopy) };
38     let w = u.clone(); //~ ERROR the method
39 }