about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-07-01 17:35:42 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-07-04 18:32:43 +1000
commitd4ecc4fb5cd82a9298956538c6d6574f7792810f (patch)
treeaf82852ccd0cf61323cf7688e7aae2b531621f0c
parent9d38c45a11e7d0faf2f62d88eaf8b6312bd6cb4a (diff)
downloadrust-d4ecc4fb5cd82a9298956538c6d6574f7792810f.tar.gz
rust-d4ecc4fb5cd82a9298956538c6d6574f7792810f.zip
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.
-rw-r--r--src/test/ui/deriving/deriving-all-codegen.rs10
-rw-r--r--src/test/ui/deriving/deriving-all-codegen.stdout166
2 files changed, 176 insertions, 0 deletions
diff --git a/src/test/ui/deriving/deriving-all-codegen.rs b/src/test/ui/deriving/deriving-all-codegen.rs
index 8c7aa4be050..1a651b2074c 100644
--- a/src/test/ui/deriving/deriving-all-codegen.rs
+++ b/src/test/ui/deriving/deriving-all-codegen.rs
@@ -39,6 +39,16 @@ struct Big {
 #[repr(packed)]
 struct Packed(u32);
 
+// An empty enum.
+#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
+enum Enum0 {}
+
+// A single-variant enum.
+#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
+enum Enum1 {
+    Single { x: 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 db6fb47d722..decf9ec332a 100644
--- a/src/test/ui/deriving/deriving-all-codegen.stdout
+++ b/src/test/ui/deriving/deriving-all-codegen.stdout
@@ -515,6 +515,172 @@ impl ::core::cmp::Ord for Packed {
     }
 }
 
+// An empty enum.
+enum Enum0 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::clone::Clone for Enum0 {
+    #[inline]
+    fn clone(&self) -> Enum0 { { *self } }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::marker::Copy for Enum0 { }
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::fmt::Debug for Enum0 {
+    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::hash::Hash for Enum0 {
+    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+impl ::core::marker::StructuralPartialEq for Enum0 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialEq for Enum0 {
+    #[inline]
+    fn eq(&self, other: &Enum0) -> bool {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+impl ::core::marker::StructuralEq for Enum0 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Eq for Enum0 {
+    #[inline]
+    #[doc(hidden)]
+    #[no_coverage]
+    fn assert_receiver_is_total_eq(&self) -> () { {} }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialOrd for Enum0 {
+    #[inline]
+    fn partial_cmp(&self, other: &Enum0)
+        -> ::core::option::Option<::core::cmp::Ordering> {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Ord for Enum0 {
+    #[inline]
+    fn cmp(&self, other: &Enum0) -> ::core::cmp::Ordering {
+        unsafe { ::core::intrinsics::unreachable() }
+    }
+}
+
+// A single-variant enum.
+enum Enum1 {
+    Single {
+        x: u32,
+    },
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::clone::Clone for Enum1 {
+    #[inline]
+    fn clone(&self) -> Enum1 {
+        match (&*self,) {
+            (&Enum1::Single { x: ref __self_0 },) =>
+                Enum1::Single { x: ::core::clone::Clone::clone(&*__self_0) },
+        }
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::fmt::Debug for Enum1 {
+    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+        match (&*self,) {
+            (&Enum1::Single { x: ref __self_0 },) =>
+                ::core::fmt::Formatter::debug_struct_field1_finish(f,
+                    "Single", "x", &&*__self_0),
+        }
+    }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::hash::Hash for Enum1 {
+    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
+        match (&*self,) {
+            (&Enum1::Single { x: ref __self_0 },) => {
+                ::core::hash::Hash::hash(&*__self_0, state)
+            }
+        }
+    }
+}
+impl ::core::marker::StructuralPartialEq for Enum1 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialEq for Enum1 {
+    #[inline]
+    fn eq(&self, other: &Enum1) -> bool {
+        match (&*self, &*other) {
+            (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+                x: ref __arg_1_0 }) => *__self_0 == *__arg_1_0,
+        }
+    }
+    #[inline]
+    fn ne(&self, other: &Enum1) -> bool {
+        match (&*self, &*other) {
+            (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+                x: ref __arg_1_0 }) => *__self_0 != *__arg_1_0,
+        }
+    }
+}
+impl ::core::marker::StructuralEq for Enum1 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Eq for Enum1 {
+    #[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 Enum1 {
+    #[inline]
+    fn partial_cmp(&self, other: &Enum1)
+        -> ::core::option::Option<::core::cmp::Ordering> {
+        match (&*self, &*other) {
+            (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+                x: ref __arg_1_0 }) =>
+                match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+                        &*__arg_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 Enum1 {
+    #[inline]
+    fn cmp(&self, other: &Enum1) -> ::core::cmp::Ordering {
+        match (&*self, &*other) {
+            (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+                x: ref __arg_1_0 }) =>
+                match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
+                    ::core::cmp::Ordering::Equal =>
+                        ::core::cmp::Ordering::Equal,
+                    cmp => cmp,
+                },
+        }
+    }
+}
+
 // A C-like, fieldless enum.
 enum Fieldless {