From 9d38c45a11e7d0faf2f62d88eaf8b6312bd6cb4a Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 Jul 2022 16:47:12 +1000 Subject: [PATCH] Add a union to the `deriving-all-codegen.rs` test. Because `derive(Clone)` on unions triggers special behaviour. --- src/test/ui/deriving/deriving-all-codegen.rs | 8 ++++++++ .../ui/deriving/deriving-all-codegen.stdout | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/test/ui/deriving/deriving-all-codegen.rs b/src/test/ui/deriving/deriving-all-codegen.rs index 028ed9c2305..8c7aa4be050 100644 --- a/src/test/ui/deriving/deriving-all-codegen.rs +++ b/src/test/ui/deriving/deriving-all-codegen.rs @@ -66,3 +66,11 @@ enum Fielded { Y(bool), Z(Option), } + +// A union. Most builtin traits are not derivable for unions. +#[derive(Clone, Copy)] +pub union Union { + pub b: bool, + pub u: u32, + pub i: i32, +} diff --git a/src/test/ui/deriving/deriving-all-codegen.stdout b/src/test/ui/deriving/deriving-all-codegen.stdout index c24ed4237b8..db6fb47d722 100644 --- a/src/test/ui/deriving/deriving-all-codegen.stdout +++ b/src/test/ui/deriving/deriving-all-codegen.stdout @@ -1020,3 +1020,21 @@ impl ::core::cmp::Ord for Fielded { } } } + +// A union. Most builtin traits are not derivable for unions. +pub union Union { + pub b: bool, + pub u: u32, + pub i: i32, +} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::clone::Clone for Union { + #[inline] + fn clone(&self) -> Union { + { let _: ::core::clone::AssertParamIsCopy; *self } + } +} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::marker::Copy for Union { }