PartialOrd: transitivity and duality are required only if the corresponding impls exist #118108
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #87067. Currently, not even std itself upholds the requirements documented for
PartialOrd
.This is basically doing for
PartialOrd
what #81198 did forPartialEq
. However, #81198 (likely accidentally) significantly weakened the transitivity requirement, which we are avoiding here: as of today, it is the case that ifA: PartialOrd<B>
andB: PartialOrd<C>
andC: PartialOrd<D>
andA: PartialOrd<D>
all hold, then ifa < b < c < d
, we havea < d
. If we just did the same thing as #81198, we would lose that property. Therefore, we explicitly require transitivity for longer chains as well.Libs-api decided here that they are fine with applying #81198 to
PartialOrd
as well. I'm still nominating this for them again due to this change in how transitivity is handled.