-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Location
Derive macros for Ord and PartialOrd.
Summary
The derive macros for Ord and PartialOrd do not specify what the order of precedence it generates in the resulting implementation. This order matters, and makes reordering fields on a type with this derive a semver-incompatible breaking change.
Examples
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub struct MyStruct {
field_1: u32,
field_2: i32,
}
Does field_1
take precedence over field_2
when comparing two MyStruct
s?
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub enum MyEnum {
Variant_1 {
field_1: u32,
field_2: i32,
},
Variant_2 {
field_1: i32,
field_2: u32,
}
Variant_3(MyStruct),
}
Do all Variant_1
come before or after Variant_2
?
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.