incorrect_partial_ord_impl_on_ord_type false positive: Some(Ord::cmp(self, other))
#11178
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Summary
Clippy flags the following as an incorrect PartialOrd impl, with a deny-by-default correctness lint:
in favor of preferring:
But there is no correctness difference between these impl, only a stylistic difference.
Lint Name
incorrect_partial_ord_impl_on_ord_type
Reproducer
I consider this a false positive for this lint. If there is a compelling stylistic argument in favor of
self.cmp(other)
overOrd::cmp(self, other)
, that should be at most a warn-by-default style lint, not a deny-by-default correctness lint.I think neither
Some(Ord::cmp(self, other))
norSome(T::cmp(self, other))
should trigger a lint.Currently on GitHub, there are 1.6k search results for "::cmp(self" and 26k search results for "self.cmp(". Clearly there is a preference for
self.cmp(other)
but that is still a significant proportion of users who prefer to write the other, especially in macro-generated code whereself.cmp(other)
might not compile (as is the case above).Version
Additional Labels
@rustbot label +I-suggestion-causes-error
The text was updated successfully, but these errors were encountered: