From 18f84956772a66293ed91d911ff9e56a269dc685 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 24 Jun 2022 14:06:35 +1000 Subject: [PATCH] Add an interesting case to the `deriving-all-codegen.rs` test. --- src/test/ui/deriving/deriving-all-codegen.rs | 7 +- .../ui/deriving/deriving-all-codegen.stdout | 109 +++++++++++++++++- 2 files changed, 114 insertions(+), 2 deletions(-) diff --git a/src/test/ui/deriving/deriving-all-codegen.rs b/src/test/ui/deriving/deriving-all-codegen.rs index 2f6ef74ac494..028ed9c23052 100644 --- a/src/test/ui/deriving/deriving-all-codegen.rs +++ b/src/test/ui/deriving/deriving-all-codegen.rs @@ -28,12 +28,17 @@ struct Point { y: u32, } -// A long struct. +// A large struct. #[derive(Clone, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)] struct Big { b1: u32, b2: u32, b3: u32, b4: u32, b5: u32, b6: u32, b7: u32, b8:u32, } +// A packed tuple struct. +#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[repr(packed)] +struct Packed(u32); + // A C-like, fieldless enum. #[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)] enum Fieldless { diff --git a/src/test/ui/deriving/deriving-all-codegen.stdout b/src/test/ui/deriving/deriving-all-codegen.stdout index faa5a3c3ddf1..7635a4792572 100644 --- a/src/test/ui/deriving/deriving-all-codegen.stdout +++ b/src/test/ui/deriving/deriving-all-codegen.stdout @@ -244,7 +244,7 @@ impl ::core::cmp::Ord for Point { } } -// A long struct. +// A large struct. struct Big { b1: u32, b2: u32, @@ -593,6 +593,113 @@ impl ::core::cmp::Ord for Big { } } +// A packed tuple struct. +#[repr(packed)] +struct Packed(u32); +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::clone::Clone for Packed { + #[inline] + fn clone(&self) -> Packed { + { let _: ::core::clone::AssertParamIsClone; *self } + } +} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::marker::Copy for Packed { } +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::fmt::Debug for Packed { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + match *self { + Self(__self_0_0) => + ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Packed", + &&(__self_0_0)), + } + } +} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::default::Default for Packed { + #[inline] + fn default() -> Packed { Packed(::core::default::Default::default()) } +} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::hash::Hash for Packed { + fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { + match *self { + Self(__self_0_0) => { + ::core::hash::Hash::hash(&(__self_0_0), state) + } + } + } +} +impl ::core::marker::StructuralPartialEq for Packed {} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::cmp::PartialEq for Packed { + #[inline] + fn eq(&self, other: &Packed) -> bool { + match *other { + Self(__self_1_0) => + match *self { + Self(__self_0_0) => (__self_0_0) == (__self_1_0), + }, + } + } +} +impl ::core::marker::StructuralEq for Packed {} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::cmp::Eq for Packed { + #[inline] + #[doc(hidden)] + #[no_coverage] + fn assert_receiver_is_total_eq(&self) -> () { + { let _: ::core::cmp::AssertParamIsEq; } + } +} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::cmp::PartialOrd for Packed { + #[inline] + fn partial_cmp(&self, other: &Packed) + -> ::core::option::Option<::core::cmp::Ordering> { + match *other { + Self(__self_1_0) => + match *self { + Self(__self_0_0) => + match ::core::cmp::PartialOrd::partial_cmp(&(__self_0_0), + &(__self_1_0)) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + ::core::option::Option::Some(::core::cmp::Ordering::Equal), + cmp => cmp, + }, + }, + } + } +} +#[automatically_derived] +#[allow(unused_qualifications)] +impl ::core::cmp::Ord for Packed { + #[inline] + fn cmp(&self, other: &Packed) -> ::core::cmp::Ordering { + match *other { + Self(__self_1_0) => + match *self { + Self(__self_0_0) => + match ::core::cmp::Ord::cmp(&(__self_0_0), &(__self_1_0)) { + ::core::cmp::Ordering::Equal => + ::core::cmp::Ordering::Equal, + cmp => cmp, + }, + }, + } + } +} + // A C-like, fieldless enum. enum Fieldless {