Add an interesting case to the deriving-all-codegen.rs test.

This commit is contained in:
Nicholas Nethercote 2022-06-24 14:06:35 +10:00
parent 46b8c23f3e
commit 18f8495677
2 changed files with 114 additions and 2 deletions

View File

@ -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 {

View File

@ -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<u32>; *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<u32>; }
}
}
#[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 {