diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-07-01 16:47:12 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-07-04 18:29:33 +1000 |
| commit | 9d38c45a11e7d0faf2f62d88eaf8b6312bd6cb4a (patch) | |
| tree | 041fddeb7ec827cbbddbcba74ea420d4dd9b220b | |
| parent | d46c728bcda687b1cf5f3bedca3d501e797b2a0f (diff) | |
| download | rust-9d38c45a11e7d0faf2f62d88eaf8b6312bd6cb4a.tar.gz rust-9d38c45a11e7d0faf2f62d88eaf8b6312bd6cb4a.zip | |
Add a union to the `deriving-all-codegen.rs` test.
Because `derive(Clone)` on unions triggers special behaviour.
| -rw-r--r-- | src/test/ui/deriving/deriving-all-codegen.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/deriving/deriving-all-codegen.stdout | 18 |
2 files changed, 26 insertions, 0 deletions
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<i32>), } + +// 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>; *self } + } +} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::marker::Copy for Union { } |
