Skip to content

Commit d4ecc4f

Browse files
committed
Add 0-variant and 1-variant enums to the deriving-all-codegen.rs test.
Because they are interesting cases with their own code generation paths.
1 parent 9d38c45 commit d4ecc4f

File tree

2 files changed

+176
-0
lines changed

2 files changed

+176
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ struct Big {
3939
#[repr(packed)]
4040
struct Packed(u32);
4141

42+
// An empty enum.
43+
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
44+
enum Enum0 {}
45+
46+
// A single-variant enum.
47+
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
48+
enum Enum1 {
49+
Single { x: u32 }
50+
}
51+
4252
// A C-like, fieldless enum.
4353
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
4454
enum Fieldless {

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

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,172 @@ impl ::core::cmp::Ord for Packed {
515515
}
516516
}
517517

518+
// An empty enum.
519+
enum Enum0 {}
520+
#[automatically_derived]
521+
#[allow(unused_qualifications)]
522+
impl ::core::clone::Clone for Enum0 {
523+
#[inline]
524+
fn clone(&self) -> Enum0 { { *self } }
525+
}
526+
#[automatically_derived]
527+
#[allow(unused_qualifications)]
528+
impl ::core::marker::Copy for Enum0 { }
529+
#[automatically_derived]
530+
#[allow(unused_qualifications)]
531+
impl ::core::fmt::Debug for Enum0 {
532+
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
533+
unsafe { ::core::intrinsics::unreachable() }
534+
}
535+
}
536+
#[automatically_derived]
537+
#[allow(unused_qualifications)]
538+
impl ::core::hash::Hash for Enum0 {
539+
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
540+
unsafe { ::core::intrinsics::unreachable() }
541+
}
542+
}
543+
impl ::core::marker::StructuralPartialEq for Enum0 {}
544+
#[automatically_derived]
545+
#[allow(unused_qualifications)]
546+
impl ::core::cmp::PartialEq for Enum0 {
547+
#[inline]
548+
fn eq(&self, other: &Enum0) -> bool {
549+
unsafe { ::core::intrinsics::unreachable() }
550+
}
551+
}
552+
impl ::core::marker::StructuralEq for Enum0 {}
553+
#[automatically_derived]
554+
#[allow(unused_qualifications)]
555+
impl ::core::cmp::Eq for Enum0 {
556+
#[inline]
557+
#[doc(hidden)]
558+
#[no_coverage]
559+
fn assert_receiver_is_total_eq(&self) -> () { {} }
560+
}
561+
#[automatically_derived]
562+
#[allow(unused_qualifications)]
563+
impl ::core::cmp::PartialOrd for Enum0 {
564+
#[inline]
565+
fn partial_cmp(&self, other: &Enum0)
566+
-> ::core::option::Option<::core::cmp::Ordering> {
567+
unsafe { ::core::intrinsics::unreachable() }
568+
}
569+
}
570+
#[automatically_derived]
571+
#[allow(unused_qualifications)]
572+
impl ::core::cmp::Ord for Enum0 {
573+
#[inline]
574+
fn cmp(&self, other: &Enum0) -> ::core::cmp::Ordering {
575+
unsafe { ::core::intrinsics::unreachable() }
576+
}
577+
}
578+
579+
// A single-variant enum.
580+
enum Enum1 {
581+
Single {
582+
x: u32,
583+
},
584+
}
585+
#[automatically_derived]
586+
#[allow(unused_qualifications)]
587+
impl ::core::clone::Clone for Enum1 {
588+
#[inline]
589+
fn clone(&self) -> Enum1 {
590+
match (&*self,) {
591+
(&Enum1::Single { x: ref __self_0 },) =>
592+
Enum1::Single { x: ::core::clone::Clone::clone(&*__self_0) },
593+
}
594+
}
595+
}
596+
#[automatically_derived]
597+
#[allow(unused_qualifications)]
598+
impl ::core::fmt::Debug for Enum1 {
599+
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
600+
match (&*self,) {
601+
(&Enum1::Single { x: ref __self_0 },) =>
602+
::core::fmt::Formatter::debug_struct_field1_finish(f,
603+
"Single", "x", &&*__self_0),
604+
}
605+
}
606+
}
607+
#[automatically_derived]
608+
#[allow(unused_qualifications)]
609+
impl ::core::hash::Hash for Enum1 {
610+
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
611+
match (&*self,) {
612+
(&Enum1::Single { x: ref __self_0 },) => {
613+
::core::hash::Hash::hash(&*__self_0, state)
614+
}
615+
}
616+
}
617+
}
618+
impl ::core::marker::StructuralPartialEq for Enum1 {}
619+
#[automatically_derived]
620+
#[allow(unused_qualifications)]
621+
impl ::core::cmp::PartialEq for Enum1 {
622+
#[inline]
623+
fn eq(&self, other: &Enum1) -> bool {
624+
match (&*self, &*other) {
625+
(&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
626+
x: ref __arg_1_0 }) => *__self_0 == *__arg_1_0,
627+
}
628+
}
629+
#[inline]
630+
fn ne(&self, other: &Enum1) -> bool {
631+
match (&*self, &*other) {
632+
(&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
633+
x: ref __arg_1_0 }) => *__self_0 != *__arg_1_0,
634+
}
635+
}
636+
}
637+
impl ::core::marker::StructuralEq for Enum1 {}
638+
#[automatically_derived]
639+
#[allow(unused_qualifications)]
640+
impl ::core::cmp::Eq for Enum1 {
641+
#[inline]
642+
#[doc(hidden)]
643+
#[no_coverage]
644+
fn assert_receiver_is_total_eq(&self) -> () {
645+
{ let _: ::core::cmp::AssertParamIsEq<u32>; }
646+
}
647+
}
648+
#[automatically_derived]
649+
#[allow(unused_qualifications)]
650+
impl ::core::cmp::PartialOrd for Enum1 {
651+
#[inline]
652+
fn partial_cmp(&self, other: &Enum1)
653+
-> ::core::option::Option<::core::cmp::Ordering> {
654+
match (&*self, &*other) {
655+
(&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
656+
x: ref __arg_1_0 }) =>
657+
match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
658+
&*__arg_1_0) {
659+
::core::option::Option::Some(::core::cmp::Ordering::Equal)
660+
=>
661+
::core::option::Option::Some(::core::cmp::Ordering::Equal),
662+
cmp => cmp,
663+
},
664+
}
665+
}
666+
}
667+
#[automatically_derived]
668+
#[allow(unused_qualifications)]
669+
impl ::core::cmp::Ord for Enum1 {
670+
#[inline]
671+
fn cmp(&self, other: &Enum1) -> ::core::cmp::Ordering {
672+
match (&*self, &*other) {
673+
(&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
674+
x: ref __arg_1_0 }) =>
675+
match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
676+
::core::cmp::Ordering::Equal =>
677+
::core::cmp::Ordering::Equal,
678+
cmp => cmp,
679+
},
680+
}
681+
}
682+
}
683+
518684
// A C-like, fieldless enum.
519685
enum Fieldless {
520686

0 commit comments

Comments
 (0)