builtin-derive: tag → discriminant
This commit is contained in:
parent
f3c6608861
commit
ec3ac1dcd6
@ -181,8 +181,8 @@ fn cs_clone(
|
|||||||
all_fields = af;
|
all_fields = af;
|
||||||
vdata = &variant.data;
|
vdata = &variant.data;
|
||||||
}
|
}
|
||||||
EnumTag(..) | AllFieldlessEnum(..) => {
|
EnumDiscr(..) | AllFieldlessEnum(..) => {
|
||||||
cx.dcx().span_bug(trait_span, format!("enum tags in `derive({name})`",))
|
cx.dcx().span_bug(trait_span, format!("enum discriminants in `derive({name})`",))
|
||||||
}
|
}
|
||||||
StaticEnum(..) | StaticStruct(..) => {
|
StaticEnum(..) | StaticStruct(..) => {
|
||||||
cx.dcx().span_bug(trait_span, format!("associated function in `derive({name})`"))
|
cx.dcx().span_bug(trait_span, format!("associated function in `derive({name})`"))
|
||||||
|
@ -20,12 +20,12 @@ pub fn expand_deriving_partial_ord(
|
|||||||
Path(Path::new_(pathvec_std!(option::Option), vec![Box::new(ordering_ty)], PathKind::Std));
|
Path(Path::new_(pathvec_std!(option::Option), vec![Box::new(ordering_ty)], PathKind::Std));
|
||||||
|
|
||||||
// Order in which to perform matching
|
// Order in which to perform matching
|
||||||
let tag_then_data = if let Annotatable::Item(item) = item
|
let discr_then_data = if let Annotatable::Item(item) = item
|
||||||
&& let ItemKind::Enum(def, _) = &item.kind
|
&& let ItemKind::Enum(def, _) = &item.kind
|
||||||
{
|
{
|
||||||
let dataful: Vec<bool> = def.variants.iter().map(|v| !v.data.fields().is_empty()).collect();
|
let dataful: Vec<bool> = def.variants.iter().map(|v| !v.data.fields().is_empty()).collect();
|
||||||
match dataful.iter().filter(|&&b| b).count() {
|
match dataful.iter().filter(|&&b| b).count() {
|
||||||
// No data, placing the tag check first makes codegen simpler
|
// No data, placing the discriminant check first makes codegen simpler
|
||||||
0 => true,
|
0 => true,
|
||||||
1..=2 => false,
|
1..=2 => false,
|
||||||
_ => (0..dataful.len() - 1).any(|i| {
|
_ => (0..dataful.len() - 1).any(|i| {
|
||||||
@ -50,7 +50,7 @@ pub fn expand_deriving_partial_ord(
|
|||||||
attributes: thin_vec![cx.attr_word(sym::inline, span)],
|
attributes: thin_vec![cx.attr_word(sym::inline, span)],
|
||||||
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
|
||||||
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
|
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
|
||||||
cs_partial_cmp(cx, span, substr, tag_then_data)
|
cs_partial_cmp(cx, span, substr, discr_then_data)
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ fn cs_partial_cmp(
|
|||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
substr: &Substructure<'_>,
|
substr: &Substructure<'_>,
|
||||||
tag_then_data: bool,
|
discr_then_data: bool,
|
||||||
) -> BlockOrExpr {
|
) -> BlockOrExpr {
|
||||||
let test_id = Ident::new(sym::cmp, span);
|
let test_id = Ident::new(sym::cmp, span);
|
||||||
let equal_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal]));
|
let equal_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal]));
|
||||||
@ -108,12 +108,12 @@ fn cs_partial_cmp(
|
|||||||
// cmp => cmp
|
// cmp => cmp
|
||||||
// }
|
// }
|
||||||
// ```
|
// ```
|
||||||
// where `expr2` is `partial_cmp(self_tag, other_tag)`, and `expr1` is a `match`
|
// where `expr2` is `partial_cmp(self_discr, other_discr)`, and `expr1` is a `match`
|
||||||
// against the enum variants. This means that we begin by comparing the enum tags,
|
// against the enum variants. This means that we begin by comparing the enum discriminants,
|
||||||
// before either inspecting their contents (if they match), or returning
|
// before either inspecting their contents (if they match), or returning
|
||||||
// the `cmp::Ordering` of comparing the enum tags.
|
// the `cmp::Ordering` of comparing the enum discriminants.
|
||||||
// ```
|
// ```
|
||||||
// match partial_cmp(self_tag, other_tag) {
|
// match partial_cmp(self_discr, other_discr) {
|
||||||
// Some(Ordering::Equal) => match (self, other) {
|
// Some(Ordering::Equal) => match (self, other) {
|
||||||
// (Self::A(self_0), Self::A(other_0)) => partial_cmp(self_0, other_0),
|
// (Self::A(self_0), Self::A(other_0)) => partial_cmp(self_0, other_0),
|
||||||
// (Self::B(self_0), Self::B(other_0)) => partial_cmp(self_0, other_0),
|
// (Self::B(self_0), Self::B(other_0)) => partial_cmp(self_0, other_0),
|
||||||
@ -126,12 +126,12 @@ fn cs_partial_cmp(
|
|||||||
// ```
|
// ```
|
||||||
// match (self, other) {
|
// match (self, other) {
|
||||||
// (Self::A(self_0), Self::A(other_0)) => partial_cmp(self_0, other_0),
|
// (Self::A(self_0), Self::A(other_0)) => partial_cmp(self_0, other_0),
|
||||||
// _ => partial_cmp(self_tag, other_tag)
|
// _ => partial_cmp(self_discr, other_discr)
|
||||||
// }
|
// }
|
||||||
// ```
|
// ```
|
||||||
// Reference: https://github.com/rust-lang/rust/pull/103659#issuecomment-1328126354
|
// Reference: https://github.com/rust-lang/rust/pull/103659#issuecomment-1328126354
|
||||||
|
|
||||||
if !tag_then_data
|
if !discr_then_data
|
||||||
&& let ExprKind::Match(_, arms, _) = &mut expr1.kind
|
&& let ExprKind::Match(_, arms, _) = &mut expr1.kind
|
||||||
&& let Some(last) = arms.last_mut()
|
&& let Some(last) = arms.last_mut()
|
||||||
&& let PatKind::Wild = last.pat.kind
|
&& let PatKind::Wild = last.pat.kind
|
||||||
|
@ -53,7 +53,7 @@ fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) ->
|
|||||||
Struct(vdata, fields) => (substr.type_ident, *vdata, fields),
|
Struct(vdata, fields) => (substr.type_ident, *vdata, fields),
|
||||||
EnumMatching(_, v, fields) => (v.ident, &v.data, fields),
|
EnumMatching(_, v, fields) => (v.ident, &v.data, fields),
|
||||||
AllFieldlessEnum(enum_def) => return show_fieldless_enum(cx, span, enum_def, substr),
|
AllFieldlessEnum(enum_def) => return show_fieldless_enum(cx, span, enum_def, substr),
|
||||||
EnumTag(..) | StaticStruct(..) | StaticEnum(..) => {
|
EnumDiscr(..) | StaticStruct(..) | StaticEnum(..) => {
|
||||||
cx.dcx().span_bug(span, "nonsensical .fields in `#[derive(Debug)]`")
|
cx.dcx().span_bug(span, "nonsensical .fields in `#[derive(Debug)]`")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
//! `struct T(i32, char)`).
|
//! `struct T(i32, char)`).
|
||||||
//! - `EnumMatching`, when `Self` is an enum and all the arguments are the
|
//! - `EnumMatching`, when `Self` is an enum and all the arguments are the
|
||||||
//! same variant of the enum (e.g., `Some(1)`, `Some(3)` and `Some(4)`)
|
//! same variant of the enum (e.g., `Some(1)`, `Some(3)` and `Some(4)`)
|
||||||
//! - `EnumTag` when `Self` is an enum, for comparing the enum tags.
|
//! - `EnumDiscr` when `Self` is an enum, for comparing the enum discriminants.
|
||||||
//! - `StaticEnum` and `StaticStruct` for static methods, where the type
|
//! - `StaticEnum` and `StaticStruct` for static methods, where the type
|
||||||
//! being derived upon is either an enum or struct respectively. (Any
|
//! being derived upon is either an enum or struct respectively. (Any
|
||||||
//! argument with type Self is just grouped among the non-self
|
//! argument with type Self is just grouped among the non-self
|
||||||
@ -143,11 +143,11 @@
|
|||||||
//! )
|
//! )
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! For the tags,
|
//! For the discriminants,
|
||||||
//!
|
//!
|
||||||
//! ```text
|
//! ```text
|
||||||
//! EnumTag(
|
//! EnumDiscr(
|
||||||
//! &[<ident of self tag>, <ident of other tag>],
|
//! &[<ident of self discriminant>, <ident of other discriminant>],
|
||||||
//! <expr to combine with>,
|
//! <expr to combine with>,
|
||||||
//! )
|
//! )
|
||||||
//! ```
|
//! ```
|
||||||
@ -315,10 +315,10 @@ pub enum SubstructureFields<'a> {
|
|||||||
/// variant.
|
/// variant.
|
||||||
EnumMatching(usize, &'a ast::Variant, Vec<FieldInfo>),
|
EnumMatching(usize, &'a ast::Variant, Vec<FieldInfo>),
|
||||||
|
|
||||||
/// The tag of an enum. The first field is a `FieldInfo` for the tags, as
|
/// The discriminant of an enum. The first field is a `FieldInfo` for the discriminants, as
|
||||||
/// if they were fields. The second field is the expression to combine the
|
/// if they were fields. The second field is the expression to combine the
|
||||||
/// tag expression with; it will be `None` if no match is necessary.
|
/// discriminant expression with; it will be `None` if no match is necessary.
|
||||||
EnumTag(FieldInfo, Option<P<Expr>>),
|
EnumDiscr(FieldInfo, Option<P<Expr>>),
|
||||||
|
|
||||||
/// A static method where `Self` is a struct.
|
/// A static method where `Self` is a struct.
|
||||||
StaticStruct(&'a ast::VariantData, StaticFields),
|
StaticStruct(&'a ast::VariantData, StaticFields),
|
||||||
@ -1137,9 +1137,9 @@ fn expand_static_struct_method_body(
|
|||||||
/// impl ::core::cmp::PartialEq for A {
|
/// impl ::core::cmp::PartialEq for A {
|
||||||
/// #[inline]
|
/// #[inline]
|
||||||
/// fn eq(&self, other: &A) -> bool {
|
/// fn eq(&self, other: &A) -> bool {
|
||||||
/// let __self_tag = ::core::intrinsics::discriminant_value(self);
|
/// let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
/// let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
/// let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
/// __self_tag == __arg1_tag
|
/// __self_discr == __arg1_discr
|
||||||
/// && match (self, other) {
|
/// && match (self, other) {
|
||||||
/// (A::A2(__self_0), A::A2(__arg1_0)) => *__self_0 == *__arg1_0,
|
/// (A::A2(__self_0), A::A2(__arg1_0)) => *__self_0 == *__arg1_0,
|
||||||
/// _ => true,
|
/// _ => true,
|
||||||
@ -1148,7 +1148,7 @@ fn expand_static_struct_method_body(
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Creates a tag check combined with a match for a tuple of all
|
/// Creates a discriminant check combined with a match for a tuple of all
|
||||||
/// `selflike_args`, with an arm for each variant with fields, possibly an
|
/// `selflike_args`, with an arm for each variant with fields, possibly an
|
||||||
/// arm for each fieldless variant (if `unify_fieldless_variants` is not
|
/// arm for each fieldless variant (if `unify_fieldless_variants` is not
|
||||||
/// `Unify`), and possibly a default arm.
|
/// `Unify`), and possibly a default arm.
|
||||||
@ -1169,7 +1169,7 @@ fn expand_enum_method_body<'b>(
|
|||||||
let span = trait_.span;
|
let span = trait_.span;
|
||||||
let variants = &enum_def.variants;
|
let variants = &enum_def.variants;
|
||||||
|
|
||||||
// Traits that unify fieldless variants always use the tag(s).
|
// Traits that unify fieldless variants always use the discriminant(s).
|
||||||
let unify_fieldless_variants =
|
let unify_fieldless_variants =
|
||||||
self.fieldless_variants_strategy == FieldlessVariantsStrategy::Unify;
|
self.fieldless_variants_strategy == FieldlessVariantsStrategy::Unify;
|
||||||
|
|
||||||
@ -1199,25 +1199,25 @@ fn expand_enum_method_body<'b>(
|
|||||||
//
|
//
|
||||||
// e.g. for `PartialEq::eq` builds two statements:
|
// e.g. for `PartialEq::eq` builds two statements:
|
||||||
// ```
|
// ```
|
||||||
// let __self_tag = ::core::intrinsics::discriminant_value(self);
|
// let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
// let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
// let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
// ```
|
// ```
|
||||||
let get_tag_pieces = |cx: &ExtCtxt<'_>| {
|
let get_discr_pieces = |cx: &ExtCtxt<'_>| {
|
||||||
let tag_idents: Vec<_> = prefixes
|
let discr_idents: Vec<_> = prefixes
|
||||||
.iter()
|
.iter()
|
||||||
.map(|name| Ident::from_str_and_span(&format!("{name}_tag"), span))
|
.map(|name| Ident::from_str_and_span(&format!("{name}_discr"), span))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut tag_exprs: Vec<_> = tag_idents
|
let mut discr_exprs: Vec<_> = discr_idents
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&ident| cx.expr_addr_of(span, cx.expr_ident(span, ident)))
|
.map(|&ident| cx.expr_addr_of(span, cx.expr_ident(span, ident)))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let self_expr = tag_exprs.remove(0);
|
let self_expr = discr_exprs.remove(0);
|
||||||
let other_selflike_exprs = tag_exprs;
|
let other_selflike_exprs = discr_exprs;
|
||||||
let tag_field = FieldInfo { span, name: None, self_expr, other_selflike_exprs };
|
let discr_field = FieldInfo { span, name: None, self_expr, other_selflike_exprs };
|
||||||
|
|
||||||
let tag_let_stmts: ThinVec<_> = iter::zip(&tag_idents, &selflike_args)
|
let discr_let_stmts: ThinVec<_> = iter::zip(&discr_idents, &selflike_args)
|
||||||
.map(|(&ident, selflike_arg)| {
|
.map(|(&ident, selflike_arg)| {
|
||||||
let variant_value = deriving::call_intrinsic(
|
let variant_value = deriving::call_intrinsic(
|
||||||
cx,
|
cx,
|
||||||
@ -1229,7 +1229,7 @@ fn expand_enum_method_body<'b>(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
(tag_field, tag_let_stmts)
|
(discr_field, discr_let_stmts)
|
||||||
};
|
};
|
||||||
|
|
||||||
// There are some special cases involving fieldless enums where no
|
// There are some special cases involving fieldless enums where no
|
||||||
@ -1239,19 +1239,19 @@ fn expand_enum_method_body<'b>(
|
|||||||
if variants.len() > 1 {
|
if variants.len() > 1 {
|
||||||
match self.fieldless_variants_strategy {
|
match self.fieldless_variants_strategy {
|
||||||
FieldlessVariantsStrategy::Unify => {
|
FieldlessVariantsStrategy::Unify => {
|
||||||
// If the type is fieldless and the trait uses the tag and
|
// If the type is fieldless and the trait uses the discriminant and
|
||||||
// there are multiple variants, we need just an operation on
|
// there are multiple variants, we need just an operation on
|
||||||
// the tag(s).
|
// the discriminant(s).
|
||||||
let (tag_field, mut tag_let_stmts) = get_tag_pieces(cx);
|
let (discr_field, mut discr_let_stmts) = get_discr_pieces(cx);
|
||||||
let mut tag_check = self.call_substructure_method(
|
let mut discr_check = self.call_substructure_method(
|
||||||
cx,
|
cx,
|
||||||
trait_,
|
trait_,
|
||||||
type_ident,
|
type_ident,
|
||||||
nonselflike_args,
|
nonselflike_args,
|
||||||
&EnumTag(tag_field, None),
|
&EnumDiscr(discr_field, None),
|
||||||
);
|
);
|
||||||
tag_let_stmts.append(&mut tag_check.0);
|
discr_let_stmts.append(&mut discr_check.0);
|
||||||
return BlockOrExpr(tag_let_stmts, tag_check.1);
|
return BlockOrExpr(discr_let_stmts, discr_check.1);
|
||||||
}
|
}
|
||||||
FieldlessVariantsStrategy::SpecializeIfAllVariantsFieldless => {
|
FieldlessVariantsStrategy::SpecializeIfAllVariantsFieldless => {
|
||||||
return self.call_substructure_method(
|
return self.call_substructure_method(
|
||||||
@ -1266,7 +1266,7 @@ fn expand_enum_method_body<'b>(
|
|||||||
}
|
}
|
||||||
} else if variants.len() == 1 {
|
} else if variants.len() == 1 {
|
||||||
// If there is a single variant, we don't need an operation on
|
// If there is a single variant, we don't need an operation on
|
||||||
// the tag(s). Just use the most degenerate result.
|
// the discriminant(s). Just use the most degenerate result.
|
||||||
return self.call_substructure_method(
|
return self.call_substructure_method(
|
||||||
cx,
|
cx,
|
||||||
trait_,
|
trait_,
|
||||||
@ -1380,22 +1380,22 @@ fn expand_enum_method_body<'b>(
|
|||||||
cx.expr_match(span, match_arg, match_arms)
|
cx.expr_match(span, match_arg, match_arms)
|
||||||
};
|
};
|
||||||
|
|
||||||
// If the trait uses the tag and there are multiple variants, we need
|
// If the trait uses the discriminant and there are multiple variants, we need
|
||||||
// to add a tag check operation before the match. Otherwise, the match
|
// to add a discriminant check operation before the match. Otherwise, the match
|
||||||
// is enough.
|
// is enough.
|
||||||
if unify_fieldless_variants && variants.len() > 1 {
|
if unify_fieldless_variants && variants.len() > 1 {
|
||||||
let (tag_field, mut tag_let_stmts) = get_tag_pieces(cx);
|
let (discr_field, mut discr_let_stmts) = get_discr_pieces(cx);
|
||||||
|
|
||||||
// Combine a tag check with the match.
|
// Combine a discriminant check with the match.
|
||||||
let mut tag_check_plus_match = self.call_substructure_method(
|
let mut discr_check_plus_match = self.call_substructure_method(
|
||||||
cx,
|
cx,
|
||||||
trait_,
|
trait_,
|
||||||
type_ident,
|
type_ident,
|
||||||
nonselflike_args,
|
nonselflike_args,
|
||||||
&EnumTag(tag_field, Some(get_match_expr(selflike_args))),
|
&EnumDiscr(discr_field, Some(get_match_expr(selflike_args))),
|
||||||
);
|
);
|
||||||
tag_let_stmts.append(&mut tag_check_plus_match.0);
|
discr_let_stmts.append(&mut discr_check_plus_match.0);
|
||||||
BlockOrExpr(tag_let_stmts, tag_check_plus_match.1)
|
BlockOrExpr(discr_let_stmts, discr_check_plus_match.1)
|
||||||
} else {
|
} else {
|
||||||
BlockOrExpr(ThinVec::new(), Some(get_match_expr(selflike_args)))
|
BlockOrExpr(ThinVec::new(), Some(get_match_expr(selflike_args)))
|
||||||
}
|
}
|
||||||
@ -1701,16 +1701,16 @@ pub fn cs_fold<F>(
|
|||||||
rest.iter().rfold(base_expr, op)
|
rest.iter().rfold(base_expr, op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EnumTag(tag_field, match_expr) => {
|
EnumDiscr(discr_field, match_expr) => {
|
||||||
let tag_check_expr = f(cx, CsFold::Single(tag_field));
|
let discr_check_expr = f(cx, CsFold::Single(discr_field));
|
||||||
if let Some(match_expr) = match_expr {
|
if let Some(match_expr) = match_expr {
|
||||||
if use_foldl {
|
if use_foldl {
|
||||||
f(cx, CsFold::Combine(trait_span, tag_check_expr, match_expr.clone()))
|
f(cx, CsFold::Combine(trait_span, discr_check_expr, match_expr.clone()))
|
||||||
} else {
|
} else {
|
||||||
f(cx, CsFold::Combine(trait_span, match_expr.clone(), tag_check_expr))
|
f(cx, CsFold::Combine(trait_span, match_expr.clone(), discr_check_expr))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tag_check_expr
|
discr_check_expr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StaticEnum(..) | StaticStruct(..) => {
|
StaticEnum(..) | StaticStruct(..) => {
|
||||||
|
@ -66,9 +66,9 @@ fn hash_substructure(cx: &ExtCtxt<'_>, trait_span: Span, substr: &Substructure<'
|
|||||||
fields.iter().map(|field| call_hash(field.span, field.self_expr.clone())).collect();
|
fields.iter().map(|field| call_hash(field.span, field.self_expr.clone())).collect();
|
||||||
(stmts, None)
|
(stmts, None)
|
||||||
}
|
}
|
||||||
EnumTag(tag_field, match_expr) => {
|
EnumDiscr(discr_field, match_expr) => {
|
||||||
assert!(tag_field.other_selflike_exprs.is_empty());
|
assert!(discr_field.other_selflike_exprs.is_empty());
|
||||||
let stmts = thin_vec![call_hash(tag_field.span, tag_field.self_expr.clone())];
|
let stmts = thin_vec![call_hash(discr_field.span, discr_field.self_expr.clone())];
|
||||||
(stmts, match_expr.clone())
|
(stmts, match_expr.clone())
|
||||||
}
|
}
|
||||||
_ => cx.dcx().span_bug(trait_span, "impossible substructure in `derive(Hash)`"),
|
_ => cx.dcx().span_bug(trait_span, "impossible substructure in `derive(Hash)`"),
|
||||||
|
@ -1005,8 +1005,8 @@ impl ::core::default::Default for Fieldless {
|
|||||||
impl ::core::hash::Hash for Fieldless {
|
impl ::core::hash::Hash for Fieldless {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
::core::hash::Hash::hash(&__self_tag, state)
|
::core::hash::Hash::hash(&__self_discr, state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@ -1015,9 +1015,9 @@ impl ::core::marker::StructuralPartialEq for Fieldless { }
|
|||||||
impl ::core::cmp::PartialEq for Fieldless {
|
impl ::core::cmp::PartialEq for Fieldless {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &Fieldless) -> bool {
|
fn eq(&self, other: &Fieldless) -> bool {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
__self_tag == __arg1_tag
|
__self_discr == __arg1_discr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@ -1032,18 +1032,18 @@ impl ::core::cmp::PartialOrd for Fieldless {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &Fieldless)
|
fn partial_cmp(&self, other: &Fieldless)
|
||||||
-> ::core::option::Option<::core::cmp::Ordering> {
|
-> ::core::option::Option<::core::cmp::Ordering> {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
|
::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl ::core::cmp::Ord for Fieldless {
|
impl ::core::cmp::Ord for Fieldless {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &Fieldless) -> ::core::cmp::Ordering {
|
fn cmp(&self, other: &Fieldless) -> ::core::cmp::Ordering {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
|
::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1096,8 +1096,8 @@ impl ::core::default::Default for Mixed {
|
|||||||
impl ::core::hash::Hash for Mixed {
|
impl ::core::hash::Hash for Mixed {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
::core::hash::Hash::hash(&__self_tag, state);
|
::core::hash::Hash::hash(&__self_discr, state);
|
||||||
match self {
|
match self {
|
||||||
Mixed::R(__self_0) => ::core::hash::Hash::hash(__self_0, state),
|
Mixed::R(__self_0) => ::core::hash::Hash::hash(__self_0, state),
|
||||||
Mixed::S { d1: __self_0, d2: __self_1 } => {
|
Mixed::S { d1: __self_0, d2: __self_1 } => {
|
||||||
@ -1114,9 +1114,9 @@ impl ::core::marker::StructuralPartialEq for Mixed { }
|
|||||||
impl ::core::cmp::PartialEq for Mixed {
|
impl ::core::cmp::PartialEq for Mixed {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &Mixed) -> bool {
|
fn eq(&self, other: &Mixed) -> bool {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
__self_tag == __arg1_tag &&
|
__self_discr == __arg1_discr &&
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
|
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
|
||||||
*__self_0 == *__arg1_0,
|
*__self_0 == *__arg1_0,
|
||||||
@ -1143,8 +1143,8 @@ impl ::core::cmp::PartialOrd for Mixed {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &Mixed)
|
fn partial_cmp(&self, other: &Mixed)
|
||||||
-> ::core::option::Option<::core::cmp::Ordering> {
|
-> ::core::option::Option<::core::cmp::Ordering> {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
|
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
|
||||||
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
||||||
@ -1157,8 +1157,8 @@ impl ::core::cmp::PartialOrd for Mixed {
|
|||||||
cmp => cmp,
|
cmp => cmp,
|
||||||
},
|
},
|
||||||
_ =>
|
_ =>
|
||||||
::core::cmp::PartialOrd::partial_cmp(&__self_tag,
|
::core::cmp::PartialOrd::partial_cmp(&__self_discr,
|
||||||
&__arg1_tag),
|
&__arg1_discr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1166,9 +1166,9 @@ impl ::core::cmp::PartialOrd for Mixed {
|
|||||||
impl ::core::cmp::Ord for Mixed {
|
impl ::core::cmp::Ord for Mixed {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &Mixed) -> ::core::cmp::Ordering {
|
fn cmp(&self, other: &Mixed) -> ::core::cmp::Ordering {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
|
match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
|
||||||
::core::cmp::Ordering::Equal =>
|
::core::cmp::Ordering::Equal =>
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
|
(Mixed::R(__self_0), Mixed::R(__arg1_0)) =>
|
||||||
@ -1225,8 +1225,8 @@ impl ::core::fmt::Debug for Fielded {
|
|||||||
impl ::core::hash::Hash for Fielded {
|
impl ::core::hash::Hash for Fielded {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
::core::hash::Hash::hash(&__self_tag, state);
|
::core::hash::Hash::hash(&__self_discr, state);
|
||||||
match self {
|
match self {
|
||||||
Fielded::X(__self_0) => ::core::hash::Hash::hash(__self_0, state),
|
Fielded::X(__self_0) => ::core::hash::Hash::hash(__self_0, state),
|
||||||
Fielded::Y(__self_0) => ::core::hash::Hash::hash(__self_0, state),
|
Fielded::Y(__self_0) => ::core::hash::Hash::hash(__self_0, state),
|
||||||
@ -1240,9 +1240,9 @@ impl ::core::marker::StructuralPartialEq for Fielded { }
|
|||||||
impl ::core::cmp::PartialEq for Fielded {
|
impl ::core::cmp::PartialEq for Fielded {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &Fielded) -> bool {
|
fn eq(&self, other: &Fielded) -> bool {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
__self_tag == __arg1_tag &&
|
__self_discr == __arg1_discr &&
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
|
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
|
||||||
*__self_0 == *__arg1_0,
|
*__self_0 == *__arg1_0,
|
||||||
@ -1270,8 +1270,8 @@ impl ::core::cmp::PartialOrd for Fielded {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &Fielded)
|
fn partial_cmp(&self, other: &Fielded)
|
||||||
-> ::core::option::Option<::core::cmp::Ordering> {
|
-> ::core::option::Option<::core::cmp::Ordering> {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
|
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
|
||||||
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
||||||
@ -1280,8 +1280,8 @@ impl ::core::cmp::PartialOrd for Fielded {
|
|||||||
(Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
|
(Fielded::Z(__self_0), Fielded::Z(__arg1_0)) =>
|
||||||
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
||||||
_ =>
|
_ =>
|
||||||
::core::cmp::PartialOrd::partial_cmp(&__self_tag,
|
::core::cmp::PartialOrd::partial_cmp(&__self_discr,
|
||||||
&__arg1_tag),
|
&__arg1_discr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1289,9 +1289,9 @@ impl ::core::cmp::PartialOrd for Fielded {
|
|||||||
impl ::core::cmp::Ord for Fielded {
|
impl ::core::cmp::Ord for Fielded {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &Fielded) -> ::core::cmp::Ordering {
|
fn cmp(&self, other: &Fielded) -> ::core::cmp::Ordering {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
|
match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
|
||||||
::core::cmp::Ordering::Equal =>
|
::core::cmp::Ordering::Equal =>
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
|
(Fielded::X(__self_0), Fielded::X(__arg1_0)) =>
|
||||||
@ -1346,8 +1346,8 @@ impl<T: ::core::hash::Hash, U: ::core::hash::Hash> ::core::hash::Hash for
|
|||||||
EnumGeneric<T, U> {
|
EnumGeneric<T, U> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
::core::hash::Hash::hash(&__self_tag, state);
|
::core::hash::Hash::hash(&__self_discr, state);
|
||||||
match self {
|
match self {
|
||||||
EnumGeneric::One(__self_0) =>
|
EnumGeneric::One(__self_0) =>
|
||||||
::core::hash::Hash::hash(__self_0, state),
|
::core::hash::Hash::hash(__self_0, state),
|
||||||
@ -1363,9 +1363,9 @@ impl<T: ::core::cmp::PartialEq, U: ::core::cmp::PartialEq>
|
|||||||
::core::cmp::PartialEq for EnumGeneric<T, U> {
|
::core::cmp::PartialEq for EnumGeneric<T, U> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &EnumGeneric<T, U>) -> bool {
|
fn eq(&self, other: &EnumGeneric<T, U>) -> bool {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
__self_tag == __arg1_tag &&
|
__self_discr == __arg1_discr &&
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(EnumGeneric::One(__self_0), EnumGeneric::One(__arg1_0)) =>
|
(EnumGeneric::One(__self_0), EnumGeneric::One(__arg1_0)) =>
|
||||||
*__self_0 == *__arg1_0,
|
*__self_0 == *__arg1_0,
|
||||||
@ -1392,16 +1392,16 @@ impl<T: ::core::cmp::PartialOrd, U: ::core::cmp::PartialOrd>
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &EnumGeneric<T, U>)
|
fn partial_cmp(&self, other: &EnumGeneric<T, U>)
|
||||||
-> ::core::option::Option<::core::cmp::Ordering> {
|
-> ::core::option::Option<::core::cmp::Ordering> {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(EnumGeneric::One(__self_0), EnumGeneric::One(__arg1_0)) =>
|
(EnumGeneric::One(__self_0), EnumGeneric::One(__arg1_0)) =>
|
||||||
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
||||||
(EnumGeneric::Two(__self_0), EnumGeneric::Two(__arg1_0)) =>
|
(EnumGeneric::Two(__self_0), EnumGeneric::Two(__arg1_0)) =>
|
||||||
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
|
||||||
_ =>
|
_ =>
|
||||||
::core::cmp::PartialOrd::partial_cmp(&__self_tag,
|
::core::cmp::PartialOrd::partial_cmp(&__self_discr,
|
||||||
&__arg1_tag),
|
&__arg1_discr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1410,9 +1410,9 @@ impl<T: ::core::cmp::Ord, U: ::core::cmp::Ord> ::core::cmp::Ord for
|
|||||||
EnumGeneric<T, U> {
|
EnumGeneric<T, U> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &EnumGeneric<T, U>) -> ::core::cmp::Ordering {
|
fn cmp(&self, other: &EnumGeneric<T, U>) -> ::core::cmp::Ordering {
|
||||||
let __self_tag = ::core::intrinsics::discriminant_value(self);
|
let __self_discr = ::core::intrinsics::discriminant_value(self);
|
||||||
let __arg1_tag = ::core::intrinsics::discriminant_value(other);
|
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
|
||||||
match ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) {
|
match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
|
||||||
::core::cmp::Ordering::Equal =>
|
::core::cmp::Ordering::Equal =>
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(EnumGeneric::One(__self_0), EnumGeneric::One(__arg1_0)) =>
|
(EnumGeneric::One(__self_0), EnumGeneric::One(__arg1_0)) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user