Skip to content

Commit 10144e2

Browse files
committedJul 11, 2022
Handle tags better.
Currently, for the enums and comparison traits we always check the tag for equality before doing anything else. This is a bit clumsy. This commit changes things so that the tags are handled very much like a zeroth field in the enum. For `eq`/ne` this makes the code slightly cleaner. For `partial_cmp` and `cmp` it's a more notable change: in the case where the tags aren't equal, instead of having a tag equality check followed by a tag comparison, it just does a single tag comparison. The commit also improves how `Hash` works for enums: instead of having duplicated code to hash the tag for every arm within the match, we do it just once before the match. All this required replacing the `EnumNonMatchingCollapsed` value with a new `EnumTag` value. For fieldless enums the new code is particularly improved. All the code now produced is close to optimal, being very similar to what you'd write by hand.
1 parent 4bcbd76 commit 10144e2

File tree

9 files changed

+245
-329
lines changed

9 files changed

+245
-329
lines changed
 

‎compiler/rustc_builtin_macros/src/deriving/clone.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn cs_clone_simple(
148148
),
149149
}
150150
}
151-
BlockOrExpr::new_mixed(stmts, cx.expr_deref(trait_span, cx.expr_self(trait_span)))
151+
BlockOrExpr::new_mixed(stmts, Some(cx.expr_deref(trait_span, cx.expr_self(trait_span))))
152152
}
153153

154154
fn cs_clone(
@@ -177,9 +177,7 @@ fn cs_clone(
177177
all_fields = af;
178178
vdata = &variant.data;
179179
}
180-
EnumNonMatchingCollapsed(..) => {
181-
cx.span_bug(trait_span, &format!("non-matching enum variants in `derive({})`", name,))
182-
}
180+
EnumTag(..) => cx.span_bug(trait_span, &format!("enum tags in `derive({})`", name,)),
183181
StaticEnum(..) | StaticStruct(..) => {
184182
cx.span_bug(trait_span, &format!("associated function in `derive({})`", name))
185183
}

‎compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs

-10
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,6 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> Bl
7373
cx.expr_match(span, expr2, vec![eq_arm, neq_arm])
7474
}
7575
CsFold::Fieldless => cx.expr_path(equal_path.clone()),
76-
CsFold::EnumNonMatching(span, tag_tuple) => {
77-
if tag_tuple.len() != 2 {
78-
cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`")
79-
} else {
80-
let lft = cx.expr_addr_of(span, cx.expr_ident(span, tag_tuple[0]));
81-
let rgt = cx.expr_addr_of(span, cx.expr_ident(span, tag_tuple[1]));
82-
let fn_cmp_path = cx.std_path(&[sym::cmp, sym::Ord, sym::cmp]);
83-
cx.expr_call_global(span, fn_cmp_path, vec![lft, rgt])
84-
}
85-
}
8676
},
8777
);
8878
BlockOrExpr::new_expr(expr)

‎compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub fn expand_deriving_partial_eq(
5151
}
5252
CsFold::Combine(span, expr1, expr2) => cx.expr_binary(span, combiner, expr1, expr2),
5353
CsFold::Fieldless => cx.expr_bool(span, base),
54-
CsFold::EnumNonMatching(span, _tag_tuple) => cx.expr_bool(span, !base),
5554
},
5655
);
5756
BlockOrExpr::new_expr(expr)

‎compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

-11
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,6 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_
8282
cx.expr_match(span, expr2, vec![eq_arm, neq_arm])
8383
}
8484
CsFold::Fieldless => cx.expr_some(span, cx.expr_path(equal_path.clone())),
85-
CsFold::EnumNonMatching(span, tag_tuple) => {
86-
if tag_tuple.len() != 2 {
87-
cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
88-
} else {
89-
let lft = cx.expr_addr_of(span, cx.expr_ident(span, tag_tuple[0]));
90-
let rgt = cx.expr_addr_of(span, cx.expr_ident(span, tag_tuple[1]));
91-
let fn_partial_cmp_path =
92-
cx.std_path(&[sym::cmp, sym::PartialOrd, sym::partial_cmp]);
93-
cx.expr_call_global(span, fn_partial_cmp_path, vec![lft, rgt])
94-
}
95-
}
9685
},
9786
);
9887
BlockOrExpr::new_expr(expr)

‎compiler/rustc_builtin_macros/src/deriving/debug.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
4545
let (ident, vdata, fields) = match substr.fields {
4646
Struct(vdata, fields) => (substr.type_ident, *vdata, fields),
4747
EnumMatching(_, _, v, fields) => (v.ident, &v.data, fields),
48-
EnumNonMatchingCollapsed(..) | StaticStruct(..) | StaticEnum(..) => {
48+
EnumTag(..) | StaticStruct(..) | StaticEnum(..) => {
4949
cx.span_bug(span, "nonsensical .fields in `#[derive(Debug)]`")
5050
}
5151
};
@@ -176,6 +176,6 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
176176
stmts.push(names_let.unwrap());
177177
}
178178
stmts.push(values_let);
179-
BlockOrExpr::new_mixed(stmts, expr)
179+
BlockOrExpr::new_mixed(stmts, Some(expr))
180180
}
181181
}

‎compiler/rustc_builtin_macros/src/deriving/encodable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn encodable_substructure(
287287
fn_emit_enum_path,
288288
vec![encoder, cx.expr_str(trait_span, substr.type_ident.name), blk],
289289
);
290-
BlockOrExpr::new_mixed(vec![me], expr)
290+
BlockOrExpr::new_mixed(vec![me], Some(expr))
291291
}
292292

293293
_ => cx.bug("expected Struct or EnumMatching in derive(Encodable)"),

‎compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+150-158
Large diffs are not rendered by default.

‎compiler/rustc_builtin_macros/src/deriving/hash.rs

+12-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::deriving::generic::ty::*;
22
use crate::deriving::generic::*;
3-
use crate::deriving::{self, path_std, pathvec_std};
3+
use crate::deriving::{path_std, pathvec_std};
44

55
use rustc_ast::{MetaItem, Mutability};
66
use rustc_expand::base::{Annotatable, ExtCtxt};
@@ -61,32 +61,20 @@ fn hash_substructure(
6161
let expr = cx.expr_call(span, hash_path, vec![expr, state_expr.clone()]);
6262
cx.stmt_expr(expr)
6363
};
64-
let mut stmts = Vec::new();
6564

66-
let fields = match substr.fields {
67-
Struct(_, fs) | EnumMatching(_, 1, .., fs) => fs,
68-
EnumMatching(.., fs) => {
69-
let variant_value = cx.expr_addr_of(
70-
trait_span,
71-
deriving::call_intrinsic(
72-
cx,
73-
trait_span,
74-
sym::discriminant_value,
75-
vec![cx.expr_self(trait_span)],
76-
),
77-
);
78-
79-
stmts.push(call_hash(trait_span, variant_value));
80-
81-
fs
65+
let (stmts, match_expr) = match substr.fields {
66+
Struct(_, fields) | EnumMatching(.., fields) => {
67+
let stmts =
68+
fields.iter().map(|field| call_hash(field.span, field.self_expr.clone())).collect();
69+
(stmts, None)
70+
}
71+
EnumTag(tag_field, match_expr) => {
72+
assert!(tag_field.other_selflike_exprs.is_empty());
73+
let stmts = vec![call_hash(tag_field.span, tag_field.self_expr.clone())];
74+
(stmts, match_expr.clone())
8275
}
8376
_ => cx.span_bug(trait_span, "impossible substructure in `derive(Hash)`"),
8477
};
8578

86-
stmts.extend(
87-
fields
88-
.iter()
89-
.map(|FieldInfo { ref self_expr, span, .. }| call_hash(*span, self_expr.clone())),
90-
);
91-
BlockOrExpr::new_stmts(stmts)
79+
BlockOrExpr::new_mixed(stmts, match_expr)
9280
}

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

+78-118
Original file line numberDiff line numberDiff line change
@@ -766,17 +766,13 @@ enum Fieldless1 {
766766
#[allow(unused_qualifications)]
767767
impl ::core::clone::Clone for Fieldless1 {
768768
#[inline]
769-
fn clone(&self) -> Fieldless1 {
770-
match self { Fieldless1::A => Fieldless1::A, }
771-
}
769+
fn clone(&self) -> Fieldless1 { Fieldless1::A }
772770
}
773771
#[automatically_derived]
774772
#[allow(unused_qualifications)]
775773
impl ::core::fmt::Debug for Fieldless1 {
776774
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
777-
match self {
778-
Fieldless1::A => ::core::fmt::Formatter::write_str(f, "A"),
779-
}
775+
::core::fmt::Formatter::write_str(f, "A")
780776
}
781777
}
782778
#[automatically_derived]
@@ -788,18 +784,14 @@ impl ::core::default::Default for Fieldless1 {
788784
#[automatically_derived]
789785
#[allow(unused_qualifications)]
790786
impl ::core::hash::Hash for Fieldless1 {
791-
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
792-
match self { _ => {} }
793-
}
787+
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
794788
}
795789
impl ::core::marker::StructuralPartialEq for Fieldless1 {}
796790
#[automatically_derived]
797791
#[allow(unused_qualifications)]
798792
impl ::core::cmp::PartialEq for Fieldless1 {
799793
#[inline]
800-
fn eq(&self, other: &Fieldless1) -> bool {
801-
match (self, other) { _ => true, }
802-
}
794+
fn eq(&self, other: &Fieldless1) -> bool { true }
803795
}
804796
impl ::core::marker::StructuralEq for Fieldless1 {}
805797
#[automatically_derived]
@@ -816,17 +808,15 @@ impl ::core::cmp::PartialOrd for Fieldless1 {
816808
#[inline]
817809
fn partial_cmp(&self, other: &Fieldless1)
818810
-> ::core::option::Option<::core::cmp::Ordering> {
819-
match (self, other) {
820-
_ => ::core::option::Option::Some(::core::cmp::Ordering::Equal),
821-
}
811+
::core::option::Option::Some(::core::cmp::Ordering::Equal)
822812
}
823813
}
824814
#[automatically_derived]
825815
#[allow(unused_qualifications)]
826816
impl ::core::cmp::Ord for Fieldless1 {
827817
#[inline]
828818
fn cmp(&self, other: &Fieldless1) -> ::core::cmp::Ordering {
829-
match (self, other) { _ => ::core::cmp::Ordering::Equal, }
819+
::core::cmp::Ordering::Equal
830820
}
831821
}
832822

@@ -868,11 +858,8 @@ impl ::core::default::Default for Fieldless {
868858
#[allow(unused_qualifications)]
869859
impl ::core::hash::Hash for Fieldless {
870860
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
871-
match self {
872-
_ =>
873-
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
874-
state),
875-
}
861+
let __self_tag = ::core::intrinsics::discriminant_value(self);
862+
::core::hash::Hash::hash(&__self_tag, state)
876863
}
877864
}
878865
impl ::core::marker::StructuralPartialEq for Fieldless {}
@@ -883,9 +870,7 @@ impl ::core::cmp::PartialEq for Fieldless {
883870
fn eq(&self, other: &Fieldless) -> bool {
884871
let __self_tag = ::core::intrinsics::discriminant_value(self);
885872
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
886-
if __self_tag == __arg1_tag {
887-
match (self, other) { _ => true, }
888-
} else { false }
873+
__self_tag == __arg1_tag
889874
}
890875
}
891876
impl ::core::marker::StructuralEq for Fieldless {}
@@ -905,14 +890,7 @@ impl ::core::cmp::PartialOrd for Fieldless {
905890
-> ::core::option::Option<::core::cmp::Ordering> {
906891
let __self_tag = ::core::intrinsics::discriminant_value(self);
907892
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
908-
if __self_tag == __arg1_tag {
909-
match (self, other) {
910-
_ =>
911-
::core::option::Option::Some(::core::cmp::Ordering::Equal),
912-
}
913-
} else {
914-
::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
915-
}
893+
::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
916894
}
917895
}
918896
#[automatically_derived]
@@ -922,9 +900,7 @@ impl ::core::cmp::Ord for Fieldless {
922900
fn cmp(&self, other: &Fieldless) -> ::core::cmp::Ordering {
923901
let __self_tag = ::core::intrinsics::discriminant_value(self);
924902
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
925-
if __self_tag == __arg1_tag {
926-
match (self, other) { _ => ::core::cmp::Ordering::Equal, }
927-
} else { ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) }
903+
::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
928904
}
929905
}
930906

@@ -978,21 +954,15 @@ impl ::core::default::Default for Mixed {
978954
#[allow(unused_qualifications)]
979955
impl ::core::hash::Hash for Mixed {
980956
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
957+
let __self_tag = ::core::intrinsics::discriminant_value(self);
958+
::core::hash::Hash::hash(&__self_tag, state);
981959
match self {
982-
Mixed::R(__self_0) => {
983-
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
984-
state);
985-
::core::hash::Hash::hash(__self_0, state)
986-
}
960+
Mixed::R(__self_0) => ::core::hash::Hash::hash(__self_0, state),
987961
Mixed::S { d1: __self_0, d2: __self_1 } => {
988-
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
989-
state);
990962
::core::hash::Hash::hash(__self_0, state);
991963
::core::hash::Hash::hash(__self_1, state)
992964
}
993-
_ =>
994-
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
995-
state),
965+
_ => {}
996966
}
997967
}
998968
}
@@ -1004,31 +974,29 @@ impl ::core::cmp::PartialEq for Mixed {
1004974
fn eq(&self, other: &Mixed) -> bool {
1005975
let __self_tag = ::core::intrinsics::discriminant_value(self);
1006976
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1007-
if __self_tag == __arg1_tag {
1008-
match (self, other) {
1009-
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
1010-
*__self_0 == *__arg1_0,
1011-
(Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
1012-
d1: __arg1_0, d2: __arg1_1 }) =>
1013-
*__self_0 == *__arg1_0 && *__self_1 == *__arg1_1,
1014-
_ => true,
1015-
}
1016-
} else { false }
977+
__self_tag == __arg1_tag &&
978+
match (self, other) {
979+
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
980+
*__self_0 == *__arg1_0,
981+
(Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
982+
d1: __arg1_0, d2: __arg1_1 }) =>
983+
*__self_0 == *__arg1_0 && *__self_1 == *__arg1_1,
984+
_ => true,
985+
}
1017986
}
1018987
#[inline]
1019988
fn ne(&self, other: &Mixed) -> bool {
1020989
let __self_tag = ::core::intrinsics::discriminant_value(self);
1021990
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1022-
if __self_tag == __arg1_tag {
1023-
match (self, other) {
1024-
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
1025-
*__self_0 != *__arg1_0,
1026-
(Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
1027-
d1: __arg1_0, d2: __arg1_1 }) =>
1028-
*__self_0 != *__arg1_0 || *__self_1 != *__arg1_1,
1029-
_ => false,
1030-
}
1031-
} else { true }
991+
__self_tag != __arg1_tag ||
992+
match (self, other) {
993+
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
994+
*__self_0 != *__arg1_0,
995+
(Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S {
996+
d1: __arg1_0, d2: __arg1_1 }) =>
997+
*__self_0 != *__arg1_0 || *__self_1 != *__arg1_1,
998+
_ => false,
999+
}
10321000
}
10331001
}
10341002
impl ::core::marker::StructuralEq for Mixed {}
@@ -1050,7 +1018,8 @@ impl ::core::cmp::PartialOrd for Mixed {
10501018
-> ::core::option::Option<::core::cmp::Ordering> {
10511019
let __self_tag = ::core::intrinsics::discriminant_value(self);
10521020
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1053-
if __self_tag == __arg1_tag {
1021+
match ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) {
1022+
::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
10541023
match (self, other) {
10551024
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
10561025
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
@@ -1064,10 +1033,9 @@ impl ::core::cmp::PartialOrd for Mixed {
10641033
},
10651034
_ =>
10661035
::core::option::Option::Some(::core::cmp::Ordering::Equal),
1067-
}
1068-
} else {
1069-
::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
1070-
}
1036+
},
1037+
cmp => cmp,
1038+
}
10711039
}
10721040
}
10731041
#[automatically_derived]
@@ -1077,7 +1045,8 @@ impl ::core::cmp::Ord for Mixed {
10771045
fn cmp(&self, other: &Mixed) -> ::core::cmp::Ordering {
10781046
let __self_tag = ::core::intrinsics::discriminant_value(self);
10791047
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1080-
if __self_tag == __arg1_tag {
1048+
match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
1049+
::core::cmp::Ordering::Equal =>
10811050
match (self, other) {
10821051
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
10831052
::core::cmp::Ord::cmp(__self_0, __arg1_0),
@@ -1089,8 +1058,9 @@ impl ::core::cmp::Ord for Mixed {
10891058
cmp => cmp,
10901059
},
10911060
_ => ::core::cmp::Ordering::Equal,
1092-
}
1093-
} else { ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) }
1061+
},
1062+
cmp => cmp,
1063+
}
10941064
}
10951065
}
10961066

@@ -1133,22 +1103,12 @@ impl ::core::fmt::Debug for Fielded {
11331103
#[allow(unused_qualifications)]
11341104
impl ::core::hash::Hash for Fielded {
11351105
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
1106+
let __self_tag = ::core::intrinsics::discriminant_value(self);
1107+
::core::hash::Hash::hash(&__self_tag, state);
11361108
match self {
1137-
Fielded::X(__self_0) => {
1138-
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
1139-
state);
1140-
::core::hash::Hash::hash(__self_0, state)
1141-
}
1142-
Fielded::Y(__self_0) => {
1143-
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
1144-
state);
1145-
::core::hash::Hash::hash(__self_0, state)
1146-
}
1147-
Fielded::Z(__self_0) => {
1148-
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
1149-
state);
1150-
::core::hash::Hash::hash(__self_0, state)
1151-
}
1109+
Fielded::X(__self_0) => ::core::hash::Hash::hash(__self_0, state),
1110+
Fielded::Y(__self_0) => ::core::hash::Hash::hash(__self_0, state),
1111+
Fielded::Z(__self_0) => ::core::hash::Hash::hash(__self_0, state),
11521112
}
11531113
}
11541114
}
@@ -1160,33 +1120,31 @@ impl ::core::cmp::PartialEq for Fielded {
11601120
fn eq(&self, other: &Fielded) -> bool {
11611121
let __self_tag = ::core::intrinsics::discriminant_value(self);
11621122
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1163-
if __self_tag == __arg1_tag {
1164-
match (self, other) {
1165-
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1166-
*__self_0 == *__arg1_0,
1167-
(Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1168-
*__self_0 == *__arg1_0,
1169-
(Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1170-
*__self_0 == *__arg1_0,
1171-
_ => unsafe { ::core::intrinsics::unreachable() }
1172-
}
1173-
} else { false }
1123+
__self_tag == __arg1_tag &&
1124+
match (self, other) {
1125+
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1126+
*__self_0 == *__arg1_0,
1127+
(Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1128+
*__self_0 == *__arg1_0,
1129+
(Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1130+
*__self_0 == *__arg1_0,
1131+
_ => unsafe { ::core::intrinsics::unreachable() }
1132+
}
11741133
}
11751134
#[inline]
11761135
fn ne(&self, other: &Fielded) -> bool {
11771136
let __self_tag = ::core::intrinsics::discriminant_value(self);
11781137
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1179-
if __self_tag == __arg1_tag {
1180-
match (self, other) {
1181-
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1182-
*__self_0 != *__arg1_0,
1183-
(Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1184-
*__self_0 != *__arg1_0,
1185-
(Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1186-
*__self_0 != *__arg1_0,
1187-
_ => unsafe { ::core::intrinsics::unreachable() }
1188-
}
1189-
} else { true }
1138+
__self_tag != __arg1_tag ||
1139+
match (self, other) {
1140+
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
1141+
*__self_0 != *__arg1_0,
1142+
(Fielded::Y(__self_0), Fielded::Y(__arg1_0)) =>
1143+
*__self_0 != *__arg1_0,
1144+
(Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
1145+
*__self_0 != *__arg1_0,
1146+
_ => unsafe { ::core::intrinsics::unreachable() }
1147+
}
11901148
}
11911149
}
11921150
impl ::core::marker::StructuralEq for Fielded {}
@@ -1210,7 +1168,8 @@ impl ::core::cmp::PartialOrd for Fielded {
12101168
-> ::core::option::Option<::core::cmp::Ordering> {
12111169
let __self_tag = ::core::intrinsics::discriminant_value(self);
12121170
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1213-
if __self_tag == __arg1_tag {
1171+
match ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) {
1172+
::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
12141173
match (self, other) {
12151174
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
12161175
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
@@ -1219,10 +1178,9 @@ impl ::core::cmp::PartialOrd for Fielded {
12191178
(Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
12201179
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
12211180
_ => unsafe { ::core::intrinsics::unreachable() }
1222-
}
1223-
} else {
1224-
::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
1225-
}
1181+
},
1182+
cmp => cmp,
1183+
}
12261184
}
12271185
}
12281186
#[automatically_derived]
@@ -1232,7 +1190,8 @@ impl ::core::cmp::Ord for Fielded {
12321190
fn cmp(&self, other: &Fielded) -> ::core::cmp::Ordering {
12331191
let __self_tag = ::core::intrinsics::discriminant_value(self);
12341192
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1235-
if __self_tag == __arg1_tag {
1193+
match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
1194+
::core::cmp::Ordering::Equal =>
12361195
match (self, other) {
12371196
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
12381197
::core::cmp::Ord::cmp(__self_0, __arg1_0),
@@ -1241,8 +1200,9 @@ impl ::core::cmp::Ord for Fielded {
12411200
(Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
12421201
::core::cmp::Ord::cmp(__self_0, __arg1_0),
12431202
_ => unsafe { ::core::intrinsics::unreachable() }
1244-
}
1245-
} else { ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) }
1203+
},
1204+
cmp => cmp,
1205+
}
12461206
}
12471207
}
12481208

0 commit comments

Comments
 (0)
Please sign in to comment.