]> git.proxmox.com Git - rustc.git/blame - 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
CommitLineData
9e0c209e 1#![feature(untagged_unions)]
1a4d82fc 2
e74abb32
XL
3use std::mem::ManuallyDrop;
4
1b1a35ee 5#[derive(Clone)] //~ ERROR the trait bound `U1: Copy` is not satisfied
9e0c209e
SL
6union U1 {
7 a: u8,
a7813a04 8}
223e47cc 9
9e0c209e
SL
10#[derive(Clone)]
11union U2 {
12 a: u8, // OK
223e47cc
LB
13}
14
9e0c209e
SL
15impl Copy for U2 {}
16
17#[derive(Clone, Copy)]
18union U3 {
19 a: u8, // OK
20}
a7813a04 21
9e0c209e 22#[derive(Clone, Copy)]
e74abb32 23union U4<T: Copy> {
9e0c209e
SL
24 a: T, // OK
25}
26
e74abb32
XL
27#[derive(Clone, Copy)]
28union U5<T> {
29 a: ManuallyDrop<T>, // OK
30}
31
9e0c209e
SL
32#[derive(Clone)]
33struct CloneNoCopy;
34
35fn main() {
e74abb32 36 let u = U5 { a: ManuallyDrop::new(CloneNoCopy) };
dfeec247 37 let w = u.clone(); //~ ERROR no method named `clone` found for union `U5<CloneNoCopy>`
223e47cc 38}