You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
robinkrahl opened this issue
Aug 17, 2020
· 0 comments
· Fixed by #75826
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
The documentation for the Ord and PartialOrd traits says:
When derived on enums, variants are ordered by their top-to-bottom declaration order.
But apparently, the derived implementation actually orders the variants by their discriminant. The discriminants do not necessarily match the declaration order.
JohnTitor
added
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
labels
Aug 19, 2020
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
The documentation for the
Ord
andPartialOrd
traits says:But apparently, the derived implementation actually orders the variants by their discriminant. The discriminants do not necessarily match the declaration order.
I tried this code (gist, Rust Playground):
Both enums have the same declaration order, so the output should be:
Instead, this happened:
Meta
Reproduced with both the stable and the nightly compiler on the Rust Playground
The text was updated successfully, but these errors were encountered: