Skip to content

Commit 9d38c45

Browse files
committed
Add a union to the deriving-all-codegen.rs test.
Because `derive(Clone)` on unions triggers special behaviour.
1 parent d46c728 commit 9d38c45

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/test/ui/deriving/deriving-all-codegen.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,11 @@ enum Fielded {
6666
Y(bool),
6767
Z(Option<i32>),
6868
}
69+
70+
// A union. Most builtin traits are not derivable for unions.
71+
#[derive(Clone, Copy)]
72+
pub union Union {
73+
pub b: bool,
74+
pub u: u32,
75+
pub i: i32,
76+
}

src/test/ui/deriving/deriving-all-codegen.stdout

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,3 +1020,21 @@ impl ::core::cmp::Ord for Fielded {
10201020
}
10211021
}
10221022
}
1023+
1024+
// A union. Most builtin traits are not derivable for unions.
1025+
pub union Union {
1026+
pub b: bool,
1027+
pub u: u32,
1028+
pub i: i32,
1029+
}
1030+
#[automatically_derived]
1031+
#[allow(unused_qualifications)]
1032+
impl ::core::clone::Clone for Union {
1033+
#[inline]
1034+
fn clone(&self) -> Union {
1035+
{ let _: ::core::clone::AssertParamIsCopy<Self>; *self }
1036+
}
1037+
}
1038+
#[automatically_derived]
1039+
#[allow(unused_qualifications)]
1040+
impl ::core::marker::Copy for Union { }

0 commit comments

Comments
 (0)