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 impl ::core::marker::StructuralPartialEq for Empty {}
50 #[automatically_derived]
51 impl ::core::cmp::PartialEq for Empty {
53 fn eq(&self, other: &Empty) -> bool { true }
55 impl ::core::marker::StructuralEq for Empty {}
56 #[automatically_derived]
57 impl ::core::cmp::Eq for Empty {
61 fn assert_receiver_is_total_eq(&self) -> () {}
63 #[automatically_derived]
64 impl ::core::cmp::PartialOrd for Empty {
66 fn partial_cmp(&self, other: &Empty)
67 -> ::core::option::Option<::core::cmp::Ordering> {
68 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
71 #[automatically_derived]
72 impl ::core::cmp::Ord for Empty {
74 fn cmp(&self, other: &Empty) -> ::core::cmp::Ordering {
75 ::core::cmp::Ordering::Equal
84 #[automatically_derived]
85 impl ::core::clone::Clone for Point {
87 fn clone(&self) -> Point {
88 let _: ::core::clone::AssertParamIsClone<u32>;
92 #[automatically_derived]
93 impl ::core::marker::Copy for Point { }
94 #[automatically_derived]
95 impl ::core::fmt::Debug for Point {
96 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
97 ::core::fmt::Formatter::debug_struct_field2_finish(f, "Point", "x",
98 &&self.x, "y", &&self.y)
101 #[automatically_derived]
102 impl ::core::default::Default for Point {
104 fn default() -> Point {
106 x: ::core::default::Default::default(),
107 y: ::core::default::Default::default(),
111 #[automatically_derived]
112 impl ::core::hash::Hash for Point {
113 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
114 ::core::hash::Hash::hash(&self.x, state);
115 ::core::hash::Hash::hash(&self.y, state)
118 impl ::core::marker::StructuralPartialEq for Point {}
119 #[automatically_derived]
120 impl ::core::cmp::PartialEq for Point {
122 fn eq(&self, other: &Point) -> bool {
123 self.x == other.x && self.y == other.y
126 fn ne(&self, other: &Point) -> bool {
127 self.x != other.x || self.y != other.y
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 impl ::core::marker::StructuralPartialEq for Big {}
233 #[automatically_derived]
234 impl ::core::cmp::PartialEq for Big {
236 fn eq(&self, other: &Big) -> bool {
237 self.b1 == other.b1 && self.b2 == other.b2 && self.b3 == other.b3 &&
238 self.b4 == other.b4 && self.b5 == other.b5 &&
239 self.b6 == other.b6 && self.b7 == other.b7 &&
243 fn ne(&self, other: &Big) -> bool {
244 self.b1 != other.b1 || self.b2 != other.b2 || self.b3 != other.b3 ||
245 self.b4 != other.b4 || self.b5 != other.b5 ||
246 self.b6 != other.b6 || self.b7 != other.b7 ||
250 impl ::core::marker::StructuralEq for Big {}
251 #[automatically_derived]
252 impl ::core::cmp::Eq for Big {
256 fn assert_receiver_is_total_eq(&self) -> () {
257 let _: ::core::cmp::AssertParamIsEq<u32>;
260 #[automatically_derived]
261 impl ::core::cmp::PartialOrd for Big {
263 fn partial_cmp(&self, other: &Big)
264 -> ::core::option::Option<::core::cmp::Ordering> {
265 match ::core::cmp::PartialOrd::partial_cmp(&self.b1, &other.b1) {
266 ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
267 match ::core::cmp::PartialOrd::partial_cmp(&self.b2,
269 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
271 match ::core::cmp::PartialOrd::partial_cmp(&self.b3,
273 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
275 match ::core::cmp::PartialOrd::partial_cmp(&self.b4,
277 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
279 match ::core::cmp::PartialOrd::partial_cmp(&self.b5,
281 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
283 match ::core::cmp::PartialOrd::partial_cmp(&self.b6,
285 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
287 match ::core::cmp::PartialOrd::partial_cmp(&self.b7,
289 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
291 ::core::cmp::PartialOrd::partial_cmp(&self.b8, &other.b8),
308 #[automatically_derived]
309 impl ::core::cmp::Ord for Big {
311 fn cmp(&self, other: &Big) -> ::core::cmp::Ordering {
312 match ::core::cmp::Ord::cmp(&self.b1, &other.b1) {
313 ::core::cmp::Ordering::Equal =>
314 match ::core::cmp::Ord::cmp(&self.b2, &other.b2) {
315 ::core::cmp::Ordering::Equal =>
316 match ::core::cmp::Ord::cmp(&self.b3, &other.b3) {
317 ::core::cmp::Ordering::Equal =>
318 match ::core::cmp::Ord::cmp(&self.b4, &other.b4) {
319 ::core::cmp::Ordering::Equal =>
320 match ::core::cmp::Ord::cmp(&self.b5, &other.b5) {
321 ::core::cmp::Ordering::Equal =>
322 match ::core::cmp::Ord::cmp(&self.b6, &other.b6) {
323 ::core::cmp::Ordering::Equal =>
324 match ::core::cmp::Ord::cmp(&self.b7, &other.b7) {
325 ::core::cmp::Ordering::Equal =>
326 ::core::cmp::Ord::cmp(&self.b8, &other.b8),
344 // A struct with an unsized field. Some derives are not usable in this case.
345 struct Unsized([u32]);
346 #[automatically_derived]
347 impl ::core::fmt::Debug for Unsized {
348 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
349 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Unsized",
353 #[automatically_derived]
354 impl ::core::hash::Hash for Unsized {
355 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
356 ::core::hash::Hash::hash(&self.0, state)
359 impl ::core::marker::StructuralPartialEq for Unsized {}
360 #[automatically_derived]
361 impl ::core::cmp::PartialEq for Unsized {
363 fn eq(&self, other: &Unsized) -> bool { self.0 == other.0 }
365 fn ne(&self, other: &Unsized) -> bool { self.0 != other.0 }
367 impl ::core::marker::StructuralEq for Unsized {}
368 #[automatically_derived]
369 impl ::core::cmp::Eq for Unsized {
373 fn assert_receiver_is_total_eq(&self) -> () {
374 let _: ::core::cmp::AssertParamIsEq<[u32]>;
377 #[automatically_derived]
378 impl ::core::cmp::PartialOrd for Unsized {
380 fn partial_cmp(&self, other: &Unsized)
381 -> ::core::option::Option<::core::cmp::Ordering> {
382 ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
385 #[automatically_derived]
386 impl ::core::cmp::Ord for Unsized {
388 fn cmp(&self, other: &Unsized) -> ::core::cmp::Ordering {
389 ::core::cmp::Ord::cmp(&self.0, &other.0)
393 // A packed tuple struct that impls `Copy`.
395 struct PackedCopy(u32);
396 #[automatically_derived]
397 impl ::core::clone::Clone for PackedCopy {
399 fn clone(&self) -> PackedCopy {
400 let _: ::core::clone::AssertParamIsClone<u32>;
404 #[automatically_derived]
405 impl ::core::marker::Copy for PackedCopy { }
406 #[automatically_derived]
407 impl ::core::fmt::Debug for PackedCopy {
408 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
409 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "PackedCopy",
413 #[automatically_derived]
414 impl ::core::default::Default for PackedCopy {
416 fn default() -> PackedCopy {
417 PackedCopy(::core::default::Default::default())
420 #[automatically_derived]
421 impl ::core::hash::Hash for PackedCopy {
422 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
423 ::core::hash::Hash::hash(&{ self.0 }, state)
426 impl ::core::marker::StructuralPartialEq for PackedCopy {}
427 #[automatically_derived]
428 impl ::core::cmp::PartialEq for PackedCopy {
430 fn eq(&self, other: &PackedCopy) -> bool { { self.0 } == { other.0 } }
432 fn ne(&self, other: &PackedCopy) -> bool { { self.0 } != { other.0 } }
434 impl ::core::marker::StructuralEq for PackedCopy {}
435 #[automatically_derived]
436 impl ::core::cmp::Eq for PackedCopy {
440 fn assert_receiver_is_total_eq(&self) -> () {
441 let _: ::core::cmp::AssertParamIsEq<u32>;
444 #[automatically_derived]
445 impl ::core::cmp::PartialOrd for PackedCopy {
447 fn partial_cmp(&self, other: &PackedCopy)
448 -> ::core::option::Option<::core::cmp::Ordering> {
449 ::core::cmp::PartialOrd::partial_cmp(&{ self.0 }, &{ other.0 })
452 #[automatically_derived]
453 impl ::core::cmp::Ord for PackedCopy {
455 fn cmp(&self, other: &PackedCopy) -> ::core::cmp::Ordering {
456 ::core::cmp::Ord::cmp(&{ self.0 }, &{ other.0 })
460 // A packed tuple struct that does not impl `Copy`. Note that the alignment of
461 // the field must be 1 for this code to be valid. Otherwise it triggers an
462 // error "`#[derive]` can't be used on a `#[repr(packed)]` struct that does not
463 // derive Copy (error E0133)" at MIR building time. This is a weird case and
464 // it's possible that this struct is not supposed to work, but for now it does.
466 struct PackedNonCopy(u8);
467 #[automatically_derived]
468 impl ::core::clone::Clone for PackedNonCopy {
470 fn clone(&self) -> PackedNonCopy {
471 let Self(ref __self_0_0) = *self;
472 PackedNonCopy(::core::clone::Clone::clone(__self_0_0))
475 #[automatically_derived]
476 impl ::core::fmt::Debug for PackedNonCopy {
477 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
478 let Self(ref __self_0_0) = *self;
479 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "PackedNonCopy",
483 #[automatically_derived]
484 impl ::core::default::Default for PackedNonCopy {
486 fn default() -> PackedNonCopy {
487 PackedNonCopy(::core::default::Default::default())
490 #[automatically_derived]
491 impl ::core::hash::Hash for PackedNonCopy {
492 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
493 let Self(ref __self_0_0) = *self;
494 ::core::hash::Hash::hash(__self_0_0, state)
497 impl ::core::marker::StructuralPartialEq for PackedNonCopy {}
498 #[automatically_derived]
499 impl ::core::cmp::PartialEq for PackedNonCopy {
501 fn eq(&self, other: &PackedNonCopy) -> bool {
502 let Self(ref __self_0_0) = *self;
503 let Self(ref __self_1_0) = *other;
504 *__self_0_0 == *__self_1_0
507 fn ne(&self, other: &PackedNonCopy) -> bool {
508 let Self(ref __self_0_0) = *self;
509 let Self(ref __self_1_0) = *other;
510 *__self_0_0 != *__self_1_0
513 impl ::core::marker::StructuralEq for PackedNonCopy {}
514 #[automatically_derived]
515 impl ::core::cmp::Eq for PackedNonCopy {
519 fn assert_receiver_is_total_eq(&self) -> () {
520 let _: ::core::cmp::AssertParamIsEq<u8>;
523 #[automatically_derived]
524 impl ::core::cmp::PartialOrd for PackedNonCopy {
526 fn partial_cmp(&self, other: &PackedNonCopy)
527 -> ::core::option::Option<::core::cmp::Ordering> {
528 let Self(ref __self_0_0) = *self;
529 let Self(ref __self_1_0) = *other;
530 ::core::cmp::PartialOrd::partial_cmp(__self_0_0, __self_1_0)
533 #[automatically_derived]
534 impl ::core::cmp::Ord for PackedNonCopy {
536 fn cmp(&self, other: &PackedNonCopy) -> ::core::cmp::Ordering {
537 let Self(ref __self_0_0) = *self;
538 let Self(ref __self_1_0) = *other;
539 ::core::cmp::Ord::cmp(__self_0_0, __self_1_0)
545 #[automatically_derived]
546 impl ::core::clone::Clone for Enum0 {
548 fn clone(&self) -> Enum0 { *self }
550 #[automatically_derived]
551 impl ::core::marker::Copy for Enum0 { }
552 #[automatically_derived]
553 impl ::core::fmt::Debug for Enum0 {
554 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
555 unsafe { ::core::intrinsics::unreachable() }
558 #[automatically_derived]
559 impl ::core::hash::Hash for Enum0 {
560 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
561 unsafe { ::core::intrinsics::unreachable() }
564 impl ::core::marker::StructuralPartialEq for Enum0 {}
565 #[automatically_derived]
566 impl ::core::cmp::PartialEq for Enum0 {
568 fn eq(&self, other: &Enum0) -> bool {
569 unsafe { ::core::intrinsics::unreachable() }
572 impl ::core::marker::StructuralEq for Enum0 {}
573 #[automatically_derived]
574 impl ::core::cmp::Eq for Enum0 {
578 fn assert_receiver_is_total_eq(&self) -> () {}
580 #[automatically_derived]
581 impl ::core::cmp::PartialOrd for Enum0 {
583 fn partial_cmp(&self, other: &Enum0)
584 -> ::core::option::Option<::core::cmp::Ordering> {
585 unsafe { ::core::intrinsics::unreachable() }
588 #[automatically_derived]
589 impl ::core::cmp::Ord for Enum0 {
591 fn cmp(&self, other: &Enum0) -> ::core::cmp::Ordering {
592 unsafe { ::core::intrinsics::unreachable() }
596 // A single-variant enum.
602 #[automatically_derived]
603 impl ::core::clone::Clone for Enum1 {
605 fn clone(&self) -> Enum1 {
607 Enum1::Single { x: __self_0 } =>
608 Enum1::Single { x: ::core::clone::Clone::clone(__self_0) },
612 #[automatically_derived]
613 impl ::core::fmt::Debug for Enum1 {
614 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
616 Enum1::Single { x: __self_0 } =>
617 ::core::fmt::Formatter::debug_struct_field1_finish(f,
618 "Single", "x", &__self_0),
622 #[automatically_derived]
623 impl ::core::hash::Hash for Enum1 {
624 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
626 Enum1::Single { x: __self_0 } =>
627 ::core::hash::Hash::hash(__self_0, state),
631 impl ::core::marker::StructuralPartialEq for Enum1 {}
632 #[automatically_derived]
633 impl ::core::cmp::PartialEq for Enum1 {
635 fn eq(&self, other: &Enum1) -> bool {
636 match (self, other) {
637 (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) =>
638 *__self_0 == *__arg1_0,
642 fn ne(&self, other: &Enum1) -> bool {
643 match (self, other) {
644 (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) =>
645 *__self_0 != *__arg1_0,
649 impl ::core::marker::StructuralEq for Enum1 {}
650 #[automatically_derived]
651 impl ::core::cmp::Eq for Enum1 {
655 fn assert_receiver_is_total_eq(&self) -> () {
656 let _: ::core::cmp::AssertParamIsEq<u32>;
659 #[automatically_derived]
660 impl ::core::cmp::PartialOrd for Enum1 {
662 fn partial_cmp(&self, other: &Enum1)
663 -> ::core::option::Option<::core::cmp::Ordering> {
664 match (self, other) {
665 (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) =>
666 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
670 #[automatically_derived]
671 impl ::core::cmp::Ord for Enum1 {
673 fn cmp(&self, other: &Enum1) -> ::core::cmp::Ordering {
674 match (self, other) {
675 (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) =>
676 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
681 // A C-like, fieldless enum with a single variant.
687 #[automatically_derived]
688 impl ::core::clone::Clone for Fieldless1 {
690 fn clone(&self) -> Fieldless1 { Fieldless1::A }
692 #[automatically_derived]
693 impl ::core::fmt::Debug for Fieldless1 {
694 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
695 ::core::fmt::Formatter::write_str(f, "A")
698 #[automatically_derived]
699 impl ::core::default::Default for Fieldless1 {
701 fn default() -> Fieldless1 { Self::A }
703 #[automatically_derived]
704 impl ::core::hash::Hash for Fieldless1 {
705 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
707 impl ::core::marker::StructuralPartialEq for Fieldless1 {}
708 #[automatically_derived]
709 impl ::core::cmp::PartialEq for Fieldless1 {
711 fn eq(&self, other: &Fieldless1) -> bool { true }
713 impl ::core::marker::StructuralEq for Fieldless1 {}
714 #[automatically_derived]
715 impl ::core::cmp::Eq for Fieldless1 {
719 fn assert_receiver_is_total_eq(&self) -> () {}
721 #[automatically_derived]
722 impl ::core::cmp::PartialOrd for Fieldless1 {
724 fn partial_cmp(&self, other: &Fieldless1)
725 -> ::core::option::Option<::core::cmp::Ordering> {
726 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
729 #[automatically_derived]
730 impl ::core::cmp::Ord for Fieldless1 {
732 fn cmp(&self, other: &Fieldless1) -> ::core::cmp::Ordering {
733 ::core::cmp::Ordering::Equal
737 // A C-like, fieldless enum.
745 #[automatically_derived]
746 impl ::core::clone::Clone for Fieldless {
748 fn clone(&self) -> Fieldless { *self }
750 #[automatically_derived]
751 impl ::core::marker::Copy for Fieldless { }
752 #[automatically_derived]
753 impl ::core::fmt::Debug for Fieldless {
754 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
756 Fieldless::A => ::core::fmt::Formatter::write_str(f, "A"),
757 Fieldless::B => ::core::fmt::Formatter::write_str(f, "B"),
758 Fieldless::C => ::core::fmt::Formatter::write_str(f, "C"),
762 #[automatically_derived]
763 impl ::core::default::Default for Fieldless {
765 fn default() -> Fieldless { Self::A }
767 #[automatically_derived]
768 impl ::core::hash::Hash for Fieldless {
769 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
770 let __self_tag = ::core::intrinsics::discriminant_value(self);
771 ::core::hash::Hash::hash(&__self_tag, state)
774 impl ::core::marker::StructuralPartialEq for Fieldless {}
775 #[automatically_derived]
776 impl ::core::cmp::PartialEq for Fieldless {
778 fn eq(&self, other: &Fieldless) -> bool {
779 let __self_tag = ::core::intrinsics::discriminant_value(self);
780 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
781 __self_tag == __arg1_tag
784 impl ::core::marker::StructuralEq for Fieldless {}
785 #[automatically_derived]
786 impl ::core::cmp::Eq for Fieldless {
790 fn assert_receiver_is_total_eq(&self) -> () {}
792 #[automatically_derived]
793 impl ::core::cmp::PartialOrd for Fieldless {
795 fn partial_cmp(&self, other: &Fieldless)
796 -> ::core::option::Option<::core::cmp::Ordering> {
797 let __self_tag = ::core::intrinsics::discriminant_value(self);
798 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
799 ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
802 #[automatically_derived]
803 impl ::core::cmp::Ord for Fieldless {
805 fn cmp(&self, other: &Fieldless) -> ::core::cmp::Ordering {
806 let __self_tag = ::core::intrinsics::discriminant_value(self);
807 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
808 ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
812 // An enum with multiple fieldless and fielded variants.
824 #[automatically_derived]
825 impl ::core::clone::Clone for Mixed {
827 fn clone(&self) -> Mixed {
828 let _: ::core::clone::AssertParamIsClone<u32>;
832 #[automatically_derived]
833 impl ::core::marker::Copy for Mixed { }
834 #[automatically_derived]
835 impl ::core::fmt::Debug for Mixed {
836 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
838 Mixed::P => ::core::fmt::Formatter::write_str(f, "P"),
839 Mixed::Q => ::core::fmt::Formatter::write_str(f, "Q"),
840 Mixed::R(__self_0) =>
841 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "R",
843 Mixed::S { d1: __self_0, d2: __self_1 } =>
844 ::core::fmt::Formatter::debug_struct_field2_finish(f, "S",
845 "d1", &__self_0, "d2", &__self_1),
849 #[automatically_derived]
850 impl ::core::default::Default for Mixed {
852 fn default() -> Mixed { Self::P }
854 #[automatically_derived]
855 impl ::core::hash::Hash for Mixed {
856 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
857 let __self_tag = ::core::intrinsics::discriminant_value(self);
858 ::core::hash::Hash::hash(&__self_tag, state);
860 Mixed::R(__self_0) => ::core::hash::Hash::hash(__self_0, state),
861 Mixed::S { d1: __self_0, d2: __self_1 } => {
862 ::core::hash::Hash::hash(__self_0, state);
863 ::core::hash::Hash::hash(__self_1, state)
869 impl ::core::marker::StructuralPartialEq for Mixed {}
870 #[automatically_derived]
871 impl ::core::cmp::PartialEq for Mixed {
873 fn eq(&self, other: &Mixed) -> bool {
874 let __self_tag = ::core::intrinsics::discriminant_value(self);
875 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
876 __self_tag == __arg1_tag &&
877 match (self, other) {
878 (Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
879 *__self_0 == *__arg1_0,
880 (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
881 d1: __arg1_0, d2: __arg1_1 }) =>
882 *__self_0 == *__arg1_0 && *__self_1 == *__arg1_1,
887 fn ne(&self, other: &Mixed) -> bool {
888 let __self_tag = ::core::intrinsics::discriminant_value(self);
889 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
890 __self_tag != __arg1_tag ||
891 match (self, other) {
892 (Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
893 *__self_0 != *__arg1_0,
894 (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
895 d1: __arg1_0, d2: __arg1_1 }) =>
896 *__self_0 != *__arg1_0 || *__self_1 != *__arg1_1,
901 impl ::core::marker::StructuralEq for Mixed {}
902 #[automatically_derived]
903 impl ::core::cmp::Eq for Mixed {
907 fn assert_receiver_is_total_eq(&self) -> () {
908 let _: ::core::cmp::AssertParamIsEq<u32>;
911 #[automatically_derived]
912 impl ::core::cmp::PartialOrd for Mixed {
914 fn partial_cmp(&self, other: &Mixed)
915 -> ::core::option::Option<::core::cmp::Ordering> {
916 let __self_tag = ::core::intrinsics::discriminant_value(self);
917 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
918 match ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) {
919 ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
920 match (self, other) {
921 (Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
922 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
923 (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
924 d1: __arg1_0, d2: __arg1_1 }) =>
925 match ::core::cmp::PartialOrd::partial_cmp(__self_0,
927 ::core::option::Option::Some(::core::cmp::Ordering::Equal)
928 => ::core::cmp::PartialOrd::partial_cmp(__self_1, __arg1_1),
932 ::core::option::Option::Some(::core::cmp::Ordering::Equal),
938 #[automatically_derived]
939 impl ::core::cmp::Ord for Mixed {
941 fn cmp(&self, other: &Mixed) -> ::core::cmp::Ordering {
942 let __self_tag = ::core::intrinsics::discriminant_value(self);
943 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
944 match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
945 ::core::cmp::Ordering::Equal =>
946 match (self, other) {
947 (Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
948 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
949 (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
950 d1: __arg1_0, d2: __arg1_1 }) =>
951 match ::core::cmp::Ord::cmp(__self_0, __arg1_0) {
952 ::core::cmp::Ordering::Equal =>
953 ::core::cmp::Ord::cmp(__self_1, __arg1_1),
956 _ => ::core::cmp::Ordering::Equal,
963 // An enum with no fieldless variants. Note that `Default` cannot be derived
965 enum Fielded { X(u32), Y(bool), Z(Option<i32>), }
966 #[automatically_derived]
967 impl ::core::clone::Clone for Fielded {
969 fn clone(&self) -> Fielded {
971 Fielded::X(__self_0) =>
972 Fielded::X(::core::clone::Clone::clone(__self_0)),
973 Fielded::Y(__self_0) =>
974 Fielded::Y(::core::clone::Clone::clone(__self_0)),
975 Fielded::Z(__self_0) =>
976 Fielded::Z(::core::clone::Clone::clone(__self_0)),
980 #[automatically_derived]
981 impl ::core::fmt::Debug for Fielded {
982 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
984 Fielded::X(__self_0) =>
985 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "X",
987 Fielded::Y(__self_0) =>
988 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Y",
990 Fielded::Z(__self_0) =>
991 ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Z",
996 #[automatically_derived]
997 impl ::core::hash::Hash for Fielded {
998 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
999 let __self_tag = ::core::intrinsics::discriminant_value(self);
1000 ::core::hash::Hash::hash(&__self_tag, state);
1002 Fielded::X(__self_0) => ::core::hash::Hash::hash(__self_0, state),
1003 Fielded::Y(__self_0) => ::core::hash::Hash::hash(__self_0, state),
1004 Fielded::Z(__self_0) => ::core::hash::Hash::hash(__self_0, state),
1008 impl ::core::marker::StructuralPartialEq for Fielded {}
1009 #[automatically_derived]
1010 impl ::core::cmp::PartialEq for Fielded {
1012 fn eq(&self, other: &Fielded) -> bool {
1013 let __self_tag = ::core::intrinsics::discriminant_value(self);
1014 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1015 __self_tag == __arg1_tag &&
1016 match (self, other) {
1017 (Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1018 *__self_0 == *__arg1_0,
1019 (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1020 *__self_0 == *__arg1_0,
1021 (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1022 *__self_0 == *__arg1_0,
1023 _ => unsafe { ::core::intrinsics::unreachable() }
1027 fn ne(&self, other: &Fielded) -> bool {
1028 let __self_tag = ::core::intrinsics::discriminant_value(self);
1029 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1030 __self_tag != __arg1_tag ||
1031 match (self, other) {
1032 (Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1033 *__self_0 != *__arg1_0,
1034 (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1035 *__self_0 != *__arg1_0,
1036 (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1037 *__self_0 != *__arg1_0,
1038 _ => unsafe { ::core::intrinsics::unreachable() }
1042 impl ::core::marker::StructuralEq for Fielded {}
1043 #[automatically_derived]
1044 impl ::core::cmp::Eq for Fielded {
1048 fn assert_receiver_is_total_eq(&self) -> () {
1049 let _: ::core::cmp::AssertParamIsEq<u32>;
1050 let _: ::core::cmp::AssertParamIsEq<bool>;
1051 let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
1054 #[automatically_derived]
1055 impl ::core::cmp::PartialOrd for Fielded {
1057 fn partial_cmp(&self, other: &Fielded)
1058 -> ::core::option::Option<::core::cmp::Ordering> {
1059 let __self_tag = ::core::intrinsics::discriminant_value(self);
1060 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1061 match ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) {
1062 ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
1063 match (self, other) {
1064 (Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1065 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
1066 (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1067 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
1068 (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1069 ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
1070 _ => unsafe { ::core::intrinsics::unreachable() }
1076 #[automatically_derived]
1077 impl ::core::cmp::Ord for Fielded {
1079 fn cmp(&self, other: &Fielded) -> ::core::cmp::Ordering {
1080 let __self_tag = ::core::intrinsics::discriminant_value(self);
1081 let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1082 match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
1083 ::core::cmp::Ordering::Equal =>
1084 match (self, other) {
1085 (Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1086 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
1087 (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1088 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
1089 (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1090 ::core::cmp::Ord::cmp(__self_0, __arg1_0),
1091 _ => unsafe { ::core::intrinsics::unreachable() }
1098 // A union. Most builtin traits are not derivable for unions.
1104 #[automatically_derived]
1105 impl ::core::clone::Clone for Union {
1107 fn clone(&self) -> Union {
1108 let _: ::core::clone::AssertParamIsCopy<Self>;
1112 #[automatically_derived]
1113 impl ::core::marker::Copy for Union { }