1 #![feature(prelude_import)]
3 // compile-flags: -Zunpretty=expanded
6 // This test checks the code generated for all[*] the builtin derivable traits
7 // on a variety of structs and enums. It protects against accidental changes to
8 // the generated code, and makes deliberate changes to the generated code
11 // [*] It excludes `Copy` in some cases, because that changes the code
12 // generated for `Clone`.
14 // [*] It excludes `RustcEncodable` and `RustDecodable`, which are obsolete and
15 // also require the `rustc_serialize` crate.
17 #![crate_type = "lib"]
21 use std::prelude::rust_2021::*;
27 #[automatically_derived]
28 impl ::core::clone::Clone for Empty {
30 fn clone(&self) -> Empty { *self }
32 #[automatically_derived]
33 impl ::core::marker::Copy for Empty { }
34 #[automatically_derived]
35 impl ::core::fmt::Debug for Empty {
36 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
37 ::core::fmt::Formatter::write_str(f, "Empty")
40 #[automatically_derived]
41 impl ::core::default::Default for Empty {
43 fn default() -> Empty { Empty {} }
45 #[automatically_derived]
46 impl ::core::hash::Hash for Empty {
47 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
49 #[automatically_derived]
50 impl ::core::marker::StructuralPartialEq for Empty { }
51 #[automatically_derived]
52 impl ::core::cmp::PartialEq for Empty {
54 fn eq(&self, other: &Empty) -> bool { true }
56 #[automatically_derived]
57 impl ::core::marker::StructuralEq for Empty { }
58 #[automatically_derived]
59 impl ::core::cmp::Eq for Empty {
63 fn assert_receiver_is_total_eq(&self) -> () {}
65 #[automatically_derived]
66 impl ::core::cmp::PartialOrd for Empty {
68 fn partial_cmp(&self, other: &Empty)
69 -> ::core::option::Option<::core::cmp::Ordering> {
70 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
73 #[automatically_derived]
74 impl ::core::cmp::Ord for Empty {
76 fn cmp(&self, other: &Empty) -> ::core::cmp::Ordering {
77 ::core::cmp::Ordering::Equal
86 #[automatically_derived]
87 impl ::core::clone::Clone for Point {
89 fn clone(&self) -> Point {
90 let _: ::core::clone::AssertParamIsClone<u32>;
94 #[automatically_derived]
95 impl ::core::marker::Copy for Point { }
96 #[automatically_derived]
97 impl ::core::fmt::Debug for Point {
98 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
99 ::core::fmt::Formatter::debug_struct_field2_finish(f, "Point", "x",
100 &&self.x, "y", &&self.y)
103 #[automatically_derived]
104 impl ::core::default::Default for Point {
106 fn default() -> Point {
108 x: ::core::default::Default::default(),
109 y: ::core::default::Default::default(),
113 #[automatically_derived]
114 impl ::core::hash::Hash for Point {
115 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
116 ::core::hash::Hash::hash(&self.x, state);
117 ::core::hash::Hash::hash(&self.y, state)
120 #[automatically_derived]
121 impl ::core::marker::StructuralPartialEq for Point { }
122 #[automatically_derived]
123 impl ::core::cmp::PartialEq for Point {
125 fn eq(&self, other: &Point) -> bool {
126 self.x == other.x && self.y == other.y
129 #[automatically_derived]
130 impl ::core::marker::StructuralEq for Point { }
131 #[automatically_derived]
132 impl ::core::cmp::Eq for Point {
136 fn assert_receiver_is_total_eq(&self) -> () {
137 let _: ::core::cmp::AssertParamIsEq<u32>;
140 #[automatically_derived]
141 impl ::core::cmp::PartialOrd for Point {
143 fn partial_cmp(&self, other: &Point)
144 -> ::core::option::Option<::core::cmp::Ordering> {
145 match ::core::cmp::PartialOrd::partial_cmp(&self.x, &other.x) {
146 ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
147 ::core::cmp::PartialOrd::partial_cmp(&self.y, &other.y),
152 #[automatically_derived]
153 impl ::core::cmp::Ord for Point {
155 fn cmp(&self, other: &Point) -> ::core::cmp::Ordering {
156 match ::core::cmp::Ord::cmp(&self.x, &other.x) {
157 ::core::cmp::Ordering::Equal =>
158 ::core::cmp::Ord::cmp(&self.y, &other.y),
175 #[automatically_derived]
176 impl ::core::clone::Clone for Big {
178 fn clone(&self) -> Big {
180 b1: ::core::clone::Clone::clone(&self.b1),
181 b2: ::core::clone::Clone::clone(&self.b2),
182 b3: ::core::clone::Clone::clone(&self.b3),
183 b4: ::core::clone::Clone::clone(&self.b4),
184 b5: ::core::clone::Clone::clone(&self.b5),
185 b6: ::core::clone::Clone::clone(&self.b6),
186 b7: ::core::clone::Clone::clone(&self.b7),
187 b8: ::core::clone::Clone::clone(&self.b8),
191 #[automatically_derived]
192 impl ::core::fmt::Debug for Big {
193 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
194 let names: &'static _ =
195 &["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8"];
196 let values: &[&dyn ::core::fmt::Debug] =
197 &[&&self.b1, &&self.b2, &&self.b3, &&self.b4, &&self.b5,
198 &&self.b6, &&self.b7, &&self.b8];
199 ::core::fmt::Formatter::debug_struct_fields_finish(f, "Big", names,
203 #[automatically_derived]
204 impl ::core::default::Default for Big {
206 fn default() -> Big {
208 b1: ::core::default::Default::default(),
209 b2: ::core::default::Default::default(),
210 b3: ::core::default::Default::default(),
211 b4: ::core::default::Default::default(),
212 b5: ::core::default::Default::default(),
213 b6: ::core::default::Default::default(),
214 b7: ::core::default::Default::default(),
215 b8: ::core::default::Default::default(),
219 #[automatically_derived]
220 impl ::core::hash::Hash for Big {
221 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
222 ::core::hash::Hash::hash(&self.b1, state);
223 ::core::hash::Hash::hash(&self.b2, state);
224 ::core::hash::Hash::hash(&self.b3, state);
225 ::core::hash::Hash::hash(&self.b4, state);
226 ::core::hash::Hash::hash(&self.b5, state);
227 ::core::hash::Hash::hash(&self.b6, state);
228 ::core::hash::Hash::hash(&self.b7, state);
229 ::core::hash::Hash::hash(&self.b8, state)
232 #[automatically_derived]
233 impl ::core::marker::StructuralPartialEq for Big { }
234 #[automatically_derived]
235 impl ::core::cmp::PartialEq for Big {
237 fn eq(&self, other: &Big) -> bool {
238 self.b1 == other.b1 && self.b2 == other.b2 && self.b3 == other.b3 &&
239 self.b4 == other.b4 && self.b5 == other.b5 &&
240 self.b6 == other.b6 && self.b7 == other.b7 &&
244 #[automatically_derived]
245 impl ::core::marker::StructuralEq for Big { }
246 #[automatically_derived]
247 impl ::core::cmp::Eq for Big {
251 fn assert_receiver_is_total_eq(&self) -> () {
252 let _: ::core::cmp::AssertParamIsEq<u32>;
255 #[automatically_derived]
256 impl ::core::cmp::PartialOrd for Big {
258 fn partial_cmp(&self, other: &Big)
259 -> ::core::option::Option<::core::cmp::Ordering> {
260 match ::core::cmp::PartialOrd::partial_cmp(&self.b1, &other.b1) {
261 ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
262 match ::core::cmp::PartialOrd::partial_cmp(&self.b2,
264 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
266 match ::core::cmp::PartialOrd::partial_cmp(&self.b3,
268 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
270 match ::core::cmp::PartialOrd::partial_cmp(&self.b4,
272 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
274 match ::core::cmp::PartialOrd::partial_cmp(&self.b5,
276 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
278 match ::core::cmp::PartialOrd::partial_cmp(&self.b6,
280 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
282 match ::core::cmp::PartialOrd::partial_cmp(&self.b7,
284 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
286 ::core::cmp::PartialOrd::partial_cmp(&self.b8, &other.b8),
303 #[automatically_derived]
304 impl ::core::cmp::Ord for Big {
306 fn cmp(&self, other: &Big) -> ::core::cmp::Ordering {
307 match ::core::cmp::Ord::cmp(&self.b1, &other.b1) {
308 ::core::cmp::Ordering::Equal =>
309 match ::core::cmp::Ord::cmp(&self.b2, &other.b2) {
310 ::core::cmp::Ordering::Equal =>
311 match ::core::cmp::Ord::cmp(&self.b3, &other.b3) {
312 ::core::cmp::Ordering::Equal =>
313 match ::core::cmp::Ord::cmp(&self.b4, &other.b4) {
314 ::core::cmp::Ordering::Equal =>
315 match ::core::cmp::Ord::cmp(&self.b5, &other.b5) {
316 ::core::cmp::Ordering::Equal =>
317 match ::core::cmp::Ord::cmp(&self.b6, &other.b6) {
318 ::core::cmp::Ordering::Equal =>
319 match ::core::cmp::Ord::cmp(&self.b7, &other.b7) {
320 ::core::cmp::Ordering::Equal =>
321 ::core::cmp::Ord::cmp(&self.b8, &other.b8),
339 // A struct with an unsized field. Some derives are not usable in this case.
340 struct Unsized([u32]);
341 #[automatically_derived]
342 impl ::core::fmt::Debug for Unsized {
343 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
344 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Unsized",
348 #[automatically_derived]
349 impl ::core::hash::Hash for Unsized {
350 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
351 ::core::hash::Hash::hash(&self.0, state)
354 #[automatically_derived]
355 impl ::core::marker::StructuralPartialEq for Unsized { }
356 #[automatically_derived]
357 impl ::core::cmp::PartialEq for Unsized {
359 fn eq(&self, other: &Unsized) -> bool { self.0 == other.0 }
361 #[automatically_derived]
362 impl ::core::marker::StructuralEq for Unsized { }
363 #[automatically_derived]
364 impl ::core::cmp::Eq for Unsized {
368 fn assert_receiver_is_total_eq(&self) -> () {
369 let _: ::core::cmp::AssertParamIsEq<[u32]>;
372 #[automatically_derived]
373 impl ::core::cmp::PartialOrd for Unsized {
375 fn partial_cmp(&self, other: &Unsized)
376 -> ::core::option::Option<::core::cmp::Ordering> {
377 ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
380 #[automatically_derived]
381 impl ::core::cmp::Ord for Unsized {
383 fn cmp(&self, other: &Unsized) -> ::core::cmp::Ordering {
384 ::core::cmp::Ord::cmp(&self.0, &other.0)
388 // A packed tuple struct that impls `Copy`.
390 struct PackedCopy(u32);
391 #[automatically_derived]
392 impl ::core::clone::Clone for PackedCopy {
394 fn clone(&self) -> PackedCopy {
395 let _: ::core::clone::AssertParamIsClone<u32>;
399 #[automatically_derived]
400 impl ::core::marker::Copy for PackedCopy { }
401 #[automatically_derived]
402 impl ::core::fmt::Debug for PackedCopy {
403 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
404 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "PackedCopy",
408 #[automatically_derived]
409 impl ::core::default::Default for PackedCopy {
411 fn default() -> PackedCopy {
412 PackedCopy(::core::default::Default::default())
415 #[automatically_derived]
416 impl ::core::hash::Hash for PackedCopy {
417 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
418 ::core::hash::Hash::hash(&{ self.0 }, state)
421 #[automatically_derived]
422 impl ::core::marker::StructuralPartialEq for PackedCopy { }
423 #[automatically_derived]
424 impl ::core::cmp::PartialEq for PackedCopy {
426 fn eq(&self, other: &PackedCopy) -> bool { { self.0 } == { other.0 } }
428 #[automatically_derived]
429 impl ::core::marker::StructuralEq for PackedCopy { }
430 #[automatically_derived]
431 impl ::core::cmp::Eq for PackedCopy {
435 fn assert_receiver_is_total_eq(&self) -> () {
436 let _: ::core::cmp::AssertParamIsEq<u32>;
439 #[automatically_derived]
440 impl ::core::cmp::PartialOrd for PackedCopy {
442 fn partial_cmp(&self, other: &PackedCopy)
443 -> ::core::option::Option<::core::cmp::Ordering> {
444 ::core::cmp::PartialOrd::partial_cmp(&{ self.0 }, &{ other.0 })
447 #[automatically_derived]
448 impl ::core::cmp::Ord for PackedCopy {
450 fn cmp(&self, other: &PackedCopy) -> ::core::cmp::Ordering {
451 ::core::cmp::Ord::cmp(&{ self.0 }, &{ other.0 })
455 // A packed tuple struct that does not impl `Copy`. Note that the alignment of
456 // the field must be 1 for this code to be valid. Otherwise it triggers an
457 // error "`#[derive]` can't be used on a `#[repr(packed)]` struct that does not
458 // derive Copy (error E0133)" at MIR building time. This is a weird case and
459 // it's possible that this struct is not supposed to work, but for now it does.
461 struct PackedNonCopy(u8);
462 #[automatically_derived]
463 impl ::core::clone::Clone for PackedNonCopy {
465 fn clone(&self) -> PackedNonCopy {
466 let Self(ref __self_0_0) = *self;
467 PackedNonCopy(::core::clone::Clone::clone(__self_0_0))
470 #[automatically_derived]
471 impl ::core::fmt::Debug for PackedNonCopy {
472 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
473 let Self(ref __self_0_0) = *self;
474 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "PackedNonCopy",
478 #[automatically_derived]
479 impl ::core::default::Default for PackedNonCopy {
481 fn default() -> PackedNonCopy {
482 PackedNonCopy(::core::default::Default::default())
485 #[automatically_derived]
486 impl ::core::hash::Hash for PackedNonCopy {
487 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
488 let Self(ref __self_0_0) = *self;
489 ::core::hash::Hash::hash(__self_0_0, state)
492 #[automatically_derived]
493 impl ::core::marker::StructuralPartialEq for PackedNonCopy { }
494 #[automatically_derived]
495 impl ::core::cmp::PartialEq for PackedNonCopy {
497 fn eq(&self, other: &PackedNonCopy) -> bool {
498 let Self(ref __self_0_0) = *self;
499 let Self(ref __self_1_0) = *other;
500 *__self_0_0 == *__self_1_0
503 #[automatically_derived]
504 impl ::core::marker::StructuralEq for PackedNonCopy { }
505 #[automatically_derived]
506 impl ::core::cmp::Eq for PackedNonCopy {
510 fn assert_receiver_is_total_eq(&self) -> () {
511 let _: ::core::cmp::AssertParamIsEq<u8>;
514 #[automatically_derived]
515 impl ::core::cmp::PartialOrd for PackedNonCopy {
517 fn partial_cmp(&self, other: &PackedNonCopy)
518 -> ::core::option::Option<::core::cmp::Ordering> {
519 let Self(ref __self_0_0) = *self;
520 let Self(ref __self_1_0) = *other;
521 ::core::cmp::PartialOrd::partial_cmp(__self_0_0, __self_1_0)
524 #[automatically_derived]
525 impl ::core::cmp::Ord for PackedNonCopy {
527 fn cmp(&self, other: &PackedNonCopy) -> ::core::cmp::Ordering {
528 let Self(ref __self_0_0) = *self;
529 let Self(ref __self_1_0) = *other;
530 ::core::cmp::Ord::cmp(__self_0_0, __self_1_0)
536 #[automatically_derived]
537 impl ::core::clone::Clone for Enum0 {
539 fn clone(&self) -> Enum0 { *self }
541 #[automatically_derived]
542 impl ::core::marker::Copy for Enum0 { }
543 #[automatically_derived]
544 impl ::core::fmt::Debug for Enum0 {
545 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
546 unsafe { ::core::intrinsics::unreachable() }
549 #[automatically_derived]
550 impl ::core::hash::Hash for Enum0 {
551 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
552 unsafe { ::core::intrinsics::unreachable() }
555 #[automatically_derived]
556 impl ::core::marker::StructuralPartialEq for Enum0 { }
557 #[automatically_derived]
558 impl ::core::cmp::PartialEq for Enum0 {
560 fn eq(&self, other: &Enum0) -> bool {
561 unsafe { ::core::intrinsics::unreachable() }
564 #[automatically_derived]
565 impl ::core::marker::StructuralEq for Enum0 { }
566 #[automatically_derived]
567 impl ::core::cmp::Eq for Enum0 {
571 fn assert_receiver_is_total_eq(&self) -> () {}
573 #[automatically_derived]
574 impl ::core::cmp::PartialOrd for Enum0 {
576 fn partial_cmp(&self, other: &Enum0)
577 -> ::core::option::Option<::core::cmp::Ordering> {
578 unsafe { ::core::intrinsics::unreachable() }
581 #[automatically_derived]
582 impl ::core::cmp::Ord for Enum0 {
584 fn cmp(&self, other: &Enum0) -> ::core::cmp::Ordering {
585 unsafe { ::core::intrinsics::unreachable() }
589 // A single-variant enum.
595 #[automatically_derived]
596 impl ::core::clone::Clone for Enum1 {
598 fn clone(&self) -> Enum1 {
600 Enum1::Single { x: __self_0 } =>
601 Enum1::Single { x: ::core::clone::Clone::clone(__self_0) },
605 #[automatically_derived]
606 impl ::core::fmt::Debug for Enum1 {
607 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
609 Enum1::Single { x: __self_0 } =>
610 ::core::fmt::Formatter::debug_struct_field1_finish(f,
611 "Single", "x", &__self_0),
615 #[automatically_derived]
616 impl ::core::hash::Hash for Enum1 {
617 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
619 Enum1::Single { x: __self_0 } =>
620 ::core::hash::Hash::hash(__self_0, state),
624 #[automatically_derived]
625 impl ::core::marker::StructuralPartialEq for Enum1 { }
626 #[automatically_derived]
627 impl ::core::cmp::PartialEq for Enum1 {
629 fn eq(&self, other: &Enum1) -> bool {
630 match (self, other) {
631 (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) =>
632 *__self_0 == *__arg1_0,
636 #[automatically_derived]
637 impl ::core::marker::StructuralEq for Enum1 { }
638 #[automatically_derived]
639 impl ::core::cmp::Eq for Enum1 {
643 fn assert_receiver_is_total_eq(&self) -> () {
644 let _: ::core::cmp::AssertParamIsEq<u32>;
647 #[automatically_derived]
648 impl ::core::cmp::PartialOrd for Enum1 {
650 fn partial_cmp(&self, other: &Enum1)
651 -> ::core::option::Option<::core::cmp::Ordering> {
652 match (self, other) {
653 (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) =>
654 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
658 #[automatically_derived]
659 impl ::core::cmp::Ord for Enum1 {
661 fn cmp(&self, other: &Enum1) -> ::core::cmp::Ordering {
662 match (self, other) {
663 (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) =>
664 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
669 // A C-like, fieldless enum with a single variant.
675 #[automatically_derived]
676 impl ::core::clone::Clone for Fieldless1 {
678 fn clone(&self) -> Fieldless1 { Fieldless1::A }
680 #[automatically_derived]
681 impl ::core::fmt::Debug for Fieldless1 {
682 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
683 ::core::fmt::Formatter::write_str(f, "A")
686 #[automatically_derived]
687 impl ::core::default::Default for Fieldless1 {
689 fn default() -> Fieldless1 { Self::A }
691 #[automatically_derived]
692 impl ::core::hash::Hash for Fieldless1 {
693 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
695 #[automatically_derived]
696 impl ::core::marker::StructuralPartialEq for Fieldless1 { }
697 #[automatically_derived]
698 impl ::core::cmp::PartialEq for Fieldless1 {
700 fn eq(&self, other: &Fieldless1) -> bool { true }
702 #[automatically_derived]
703 impl ::core::marker::StructuralEq for Fieldless1 { }
704 #[automatically_derived]
705 impl ::core::cmp::Eq for Fieldless1 {
709 fn assert_receiver_is_total_eq(&self) -> () {}
711 #[automatically_derived]
712 impl ::core::cmp::PartialOrd for Fieldless1 {
714 fn partial_cmp(&self, other: &Fieldless1)
715 -> ::core::option::Option<::core::cmp::Ordering> {
716 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
719 #[automatically_derived]
720 impl ::core::cmp::Ord for Fieldless1 {
722 fn cmp(&self, other: &Fieldless1) -> ::core::cmp::Ordering {
723 ::core::cmp::Ordering::Equal
727 // A C-like, fieldless enum.
735 #[automatically_derived]
736 impl ::core::clone::Clone for Fieldless {
738 fn clone(&self) -> Fieldless { *self }
740 #[automatically_derived]
741 impl ::core::marker::Copy for Fieldless { }
742 #[automatically_derived]
743 impl ::core::fmt::Debug for Fieldless {
744 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
746 Fieldless::A => ::core::fmt::Formatter::write_str(f, "A"),
747 Fieldless::B => ::core::fmt::Formatter::write_str(f, "B"),
748 Fieldless::C => ::core::fmt::Formatter::write_str(f, "C"),
752 #[automatically_derived]
753 impl ::core::default::Default for Fieldless {
755 fn default() -> Fieldless { Self::A }
757 #[automatically_derived]
758 impl ::core::hash::Hash for Fieldless {
759 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
760 let __self_tag = ::core::intrinsics::discriminant_value(self);
761 ::core::hash::Hash::hash(&__self_tag, state)
764 #[automatically_derived]
765 impl ::core::marker::StructuralPartialEq for Fieldless { }
766 #[automatically_derived]
767 impl ::core::cmp::PartialEq for Fieldless {
769 fn eq(&self, other: &Fieldless) -> bool {
770 let __self_tag = ::core::intrinsics::discriminant_value(self);
771 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
772 __self_tag == __arg1_tag
775 #[automatically_derived]
776 impl ::core::marker::StructuralEq for Fieldless { }
777 #[automatically_derived]
778 impl ::core::cmp::Eq for Fieldless {
782 fn assert_receiver_is_total_eq(&self) -> () {}
784 #[automatically_derived]
785 impl ::core::cmp::PartialOrd for Fieldless {
787 fn partial_cmp(&self, other: &Fieldless)
788 -> ::core::option::Option<::core::cmp::Ordering> {
789 let __self_tag = ::core::intrinsics::discriminant_value(self);
790 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
791 ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
794 #[automatically_derived]
795 impl ::core::cmp::Ord for Fieldless {
797 fn cmp(&self, other: &Fieldless) -> ::core::cmp::Ordering {
798 let __self_tag = ::core::intrinsics::discriminant_value(self);
799 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
800 ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
804 // An enum with multiple fieldless and fielded variants.
816 #[automatically_derived]
817 impl ::core::clone::Clone for Mixed {
819 fn clone(&self) -> Mixed {
820 let _: ::core::clone::AssertParamIsClone<u32>;
821 let _: ::core::clone::AssertParamIsClone<Option<u32>>;
822 let _: ::core::clone::AssertParamIsClone<Option<i32>>;
826 #[automatically_derived]
827 impl ::core::marker::Copy for Mixed { }
828 #[automatically_derived]
829 impl ::core::fmt::Debug for Mixed {
830 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
832 Mixed::P => ::core::fmt::Formatter::write_str(f, "P"),
833 Mixed::Q => ::core::fmt::Formatter::write_str(f, "Q"),
834 Mixed::R(__self_0) =>
835 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "R",
837 Mixed::S { d1: __self_0, d2: __self_1 } =>
838 ::core::fmt::Formatter::debug_struct_field2_finish(f, "S",
839 "d1", &__self_0, "d2", &__self_1),
843 #[automatically_derived]
844 impl ::core::default::Default for Mixed {
846 fn default() -> Mixed { Self::P }
848 #[automatically_derived]
849 impl ::core::hash::Hash for Mixed {
850 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
851 let __self_tag = ::core::intrinsics::discriminant_value(self);
852 ::core::hash::Hash::hash(&__self_tag, state);
854 Mixed::R(__self_0) => ::core::hash::Hash::hash(__self_0, state),
855 Mixed::S { d1: __self_0, d2: __self_1 } => {
856 ::core::hash::Hash::hash(__self_0, state);
857 ::core::hash::Hash::hash(__self_1, state)
863 #[automatically_derived]
864 impl ::core::marker::StructuralPartialEq for Mixed { }
865 #[automatically_derived]
866 impl ::core::cmp::PartialEq for Mixed {
868 fn eq(&self, other: &Mixed) -> bool {
869 let __self_tag = ::core::intrinsics::discriminant_value(self);
870 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
871 __self_tag == __arg1_tag &&
872 match (self, other) {
873 (Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
874 *__self_0 == *__arg1_0,
875 (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
876 d1: __arg1_0, d2: __arg1_1 }) =>
877 *__self_0 == *__arg1_0 && *__self_1 == *__arg1_1,
882 #[automatically_derived]
883 impl ::core::marker::StructuralEq for Mixed { }
884 #[automatically_derived]
885 impl ::core::cmp::Eq for Mixed {
889 fn assert_receiver_is_total_eq(&self) -> () {
890 let _: ::core::cmp::AssertParamIsEq<u32>;
891 let _: ::core::cmp::AssertParamIsEq<Option<u32>>;
892 let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
895 #[automatically_derived]
896 impl ::core::cmp::PartialOrd for Mixed {
898 fn partial_cmp(&self, other: &Mixed)
899 -> ::core::option::Option<::core::cmp::Ordering> {
900 let __self_tag = ::core::intrinsics::discriminant_value(self);
901 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
902 match ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) {
903 ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
904 match (self, other) {
905 (Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
906 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
907 (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
908 d1: __arg1_0, d2: __arg1_1 }) =>
909 match ::core::cmp::PartialOrd::partial_cmp(__self_0,
911 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
912 => ::core::cmp::PartialOrd::partial_cmp(__self_1, __arg1_1),
916 ::core::option::Option::Some(::core::cmp::Ordering::Equal),
922 #[automatically_derived]
923 impl ::core::cmp::Ord for Mixed {
925 fn cmp(&self, other: &Mixed) -> ::core::cmp::Ordering {
926 let __self_tag = ::core::intrinsics::discriminant_value(self);
927 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
928 match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
929 ::core::cmp::Ordering::Equal =>
930 match (self, other) {
931 (Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
932 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
933 (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
934 d1: __arg1_0, d2: __arg1_1 }) =>
935 match ::core::cmp::Ord::cmp(__self_0, __arg1_0) {
936 ::core::cmp::Ordering::Equal =>
937 ::core::cmp::Ord::cmp(__self_1, __arg1_1),
940 _ => ::core::cmp::Ordering::Equal,
947 // An enum with no fieldless variants. Note that `Default` cannot be derived
949 enum Fielded { X(u32), Y(bool), Z(Option<i32>), }
950 #[automatically_derived]
951 impl ::core::clone::Clone for Fielded {
953 fn clone(&self) -> Fielded {
955 Fielded::X(__self_0) =>
956 Fielded::X(::core::clone::Clone::clone(__self_0)),
957 Fielded::Y(__self_0) =>
958 Fielded::Y(::core::clone::Clone::clone(__self_0)),
959 Fielded::Z(__self_0) =>
960 Fielded::Z(::core::clone::Clone::clone(__self_0)),
964 #[automatically_derived]
965 impl ::core::fmt::Debug for Fielded {
966 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
968 Fielded::X(__self_0) =>
969 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "X",
971 Fielded::Y(__self_0) =>
972 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Y",
974 Fielded::Z(__self_0) =>
975 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Z",
980 #[automatically_derived]
981 impl ::core::hash::Hash for Fielded {
982 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
983 let __self_tag = ::core::intrinsics::discriminant_value(self);
984 ::core::hash::Hash::hash(&__self_tag, state);
986 Fielded::X(__self_0) => ::core::hash::Hash::hash(__self_0, state),
987 Fielded::Y(__self_0) => ::core::hash::Hash::hash(__self_0, state),
988 Fielded::Z(__self_0) => ::core::hash::Hash::hash(__self_0, state),
992 #[automatically_derived]
993 impl ::core::marker::StructuralPartialEq for Fielded { }
994 #[automatically_derived]
995 impl ::core::cmp::PartialEq for Fielded {
997 fn eq(&self, other: &Fielded) -> bool {
998 let __self_tag = ::core::intrinsics::discriminant_value(self);
999 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1000 __self_tag == __arg1_tag &&
1001 match (self, other) {
1002 (Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1003 *__self_0 == *__arg1_0,
1004 (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1005 *__self_0 == *__arg1_0,
1006 (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1007 *__self_0 == *__arg1_0,
1008 _ => unsafe { ::core::intrinsics::unreachable() }
1012 #[automatically_derived]
1013 impl ::core::marker::StructuralEq for Fielded { }
1014 #[automatically_derived]
1015 impl ::core::cmp::Eq for Fielded {
1019 fn assert_receiver_is_total_eq(&self) -> () {
1020 let _: ::core::cmp::AssertParamIsEq<u32>;
1021 let _: ::core::cmp::AssertParamIsEq<bool>;
1022 let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
1025 #[automatically_derived]
1026 impl ::core::cmp::PartialOrd for Fielded {
1028 fn partial_cmp(&self, other: &Fielded)
1029 -> ::core::option::Option<::core::cmp::Ordering> {
1030 let __self_tag = ::core::intrinsics::discriminant_value(self);
1031 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1032 match ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) {
1033 ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
1034 match (self, other) {
1035 (Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1036 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
1037 (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1038 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
1039 (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1040 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
1041 _ => unsafe { ::core::intrinsics::unreachable() }
1047 #[automatically_derived]
1048 impl ::core::cmp::Ord for Fielded {
1050 fn cmp(&self, other: &Fielded) -> ::core::cmp::Ordering {
1051 let __self_tag = ::core::intrinsics::discriminant_value(self);
1052 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1053 match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
1054 ::core::cmp::Ordering::Equal =>
1055 match (self, other) {
1056 (Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1057 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
1058 (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1059 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
1060 (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1061 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
1062 _ => unsafe { ::core::intrinsics::unreachable() }
1069 // A union. Most builtin traits are not derivable for unions.
1075 #[automatically_derived]
1076 impl ::core::clone::Clone for Union {
1078 fn clone(&self) -> Union {
1079 let _: ::core::clone::AssertParamIsCopy<Self>;
1083 #[automatically_derived]
1084 impl ::core::marker::Copy for Union { }