]> git.proxmox.com Git - rustc.git/blob - src/test/ui/union/union-derive-clone.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / union / union-derive-clone.rs
1 #![feature(untagged_unions)]
2
3 use std::mem::ManuallyDrop;
4
5 #[derive(Clone)] //~ ERROR the trait bound `U1: Copy` is not satisfied
6 union U1 {
7 a: u8,
8 }
9
10 #[derive(Clone)]
11 union U2 {
12 a: u8, // OK
13 }
14
15 impl Copy for U2 {}
16
17 #[derive(Clone, Copy)]
18 union U3 {
19 a: u8, // OK
20 }
21
22 #[derive(Clone, Copy)]
23 union U4<T: Copy> {
24 a: T, // OK
25 }
26
27 #[derive(Clone, Copy)]
28 union U5<T> {
29 a: ManuallyDrop<T>, // OK
30 }
31
32 #[derive(Clone)]
33 struct CloneNoCopy;
34
35 fn main() {
36 let u = U5 { a: ManuallyDrop::new(CloneNoCopy) };
37 let w = u.clone(); //~ ERROR no method named `clone` found for union `U5<CloneNoCopy>`
38 }