mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-02 06:28:20 +03:00
Avoid regression in derive(PartialOrd) for zero-variant enums
This commit is contained in:
@@ -57,8 +57,11 @@ pub(crate) fn expand_deriving_partial_ord(
|
||||
}));
|
||||
let (is_simple, substructure) = match item {
|
||||
Annotatable::Item(annitem) => match &annitem.kind {
|
||||
// For unit structs, the default generated code is better.
|
||||
// For unit structs/zero-variant enums, the default generated code is better.
|
||||
ItemKind::Struct(.., ast::VariantData::Unit(..)) => (false, default_substructure),
|
||||
ItemKind::Enum(.., enum_def) if enum_def.variants.is_empty() => {
|
||||
(false, default_substructure)
|
||||
}
|
||||
ItemKind::Struct(_, ast::Generics { params, .. }, _)
|
||||
| ItemKind::Enum(_, ast::Generics { params, .. }, _)
|
||||
if is_simple_candidate(params) =>
|
||||
|
||||
@@ -1016,7 +1016,7 @@ impl ::core::cmp::PartialOrd for Enum0 {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Enum0)
|
||||
-> ::core::option::Option<::core::cmp::Ordering> {
|
||||
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
|
||||
match *self {}
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
|
||||
Reference in New Issue
Block a user