Open kangalio opened 3 years ago
Repro: playground
@rustbot modify labels: +L-bug
Seems incredibly low risk if one of the operations is implemented in terms of the other.
Looking at the list of crates that have ignored this lint, that reasoning covers most of them. Several of them are also non-NaN float wrappers as well.
https://dtolnay.github.io/noisy-clippy/derive_ord_xor_partial_ord.html#local
In fact, I would argue the chances of getting it wrong are higher if someone manually implements both operations. That is what should be linted against: if you have explicit impls of both and one is not implemented in terms of the other.
In my application, I have a struct wrapping a
f32
, but guaranteeing non-NaN values. Therefore, this struct can have an Ord implementation.I've implemented this using:
This triggers a deny-by-default warning, telling me that I'm making my Ord and PartialOrd implementation not match (link). However, as you can see, this is not the case here.
This false alarm was easily fixed with
#[allow(clippy::derive_ord_xor_partial_ord)]
, however it may be good to