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
{{ message }}
Repository navigation
clippy::comparison_chain false positive on PartialOrd #4827
Checks comparison chains written with if that can be rewritten with match and cmp.
However it also triggers on comparison chains written with if who's compared type does not implement Ord and doesn't offer cmp.
One such example would be f64. This type implements PartialOrd but not Ord. It provides < and > operators without providing cmp.
While in theory the same concept of using match could also be applied to the result of partial_cmp, I personally find matching over Optional<Ordering> much less appealing than matching over Ordering.
Should we apply the same lint to all PartialOrd cases and change the documentation to make this the official desired behavior? Or should we consider this a bug and change the implementation, so that the lint only fires if cmp is available on the relevant type (as specified in the documentation)?
changed the title [-]`clippy::comparison_chain` false positive on PartialOrd or desired behavior[/-][+]`clippy::comparison_chain` false positive on PartialOrd[/+]on Nov 19, 2019
Activity
flip1995 commentedon Nov 19, 2019
We should only lint for types, that implement
Ord. It would be possible to implement the same lint forPartialOrd, but put it in thepedanticgroup.[-]`clippy::comparison_chain` false positive on PartialOrd or desired behavior[/-][+]`clippy::comparison_chain` false positive on PartialOrd[/+][comparison_chain] rust-lang#4827 Check `core::cmp::Ord` is implemented
[comparison_chain] rust-lang#4827 Check `core::cmp::Ord` is implemented
Rollup merge of rust-lang#4842 - timbodeit:comparison-chain-false-pos…
Auto merge of #4855 - phansch:rollup-x7yail7, r=phansch
submodules: update clippy from 7b8e829 to 7a943a9