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