Fire clippy::op_ref on PartialOrd but !Ord types - #4876
Conversation
|
CI failure is an extra lint trigger: Context: rust-clippy/tests/ui/op_ref.rs Lines 17 to 22 in 7a943a9 Relevant arm: rust-clippy/clippy_lints/src/eq_op.rs Lines 163 to 180 in 7a943a9 Removing the ref here is wrong due to not having |
|
The "FP" is the same as #2597, it is not really a FP tough. In such a case the correct suggestion would be to write |
|
rust-lang/rust#66941 has been merged and this patch is now required to get clippy building with latest rust again. Should I just change the test expected output and mark it as a case of #2597? I'm honestly not certain how best to go about fixing that issue (and fixing it in this PR is probably outside of scope). |
|
I'm on this myself (there was also another PR, that broke Clippy). It stopped linting for this case, which is good (?). But it's weird, that it returned |
|
Note that |
Some context: this appears to be the only usage of
.ord_trait()in the compiler. I've a PR that tries to remove it. It's definitely not correct here, though! Example:On the above snippet,
clippy::op_refdoes not fire unless we also deriveOrddue to the use of.ord_trait()here meaning we gate the lint on implementingOrd, rather than justPartialOrdwhich is the trait actually required to use comparison operators.changelog: Fix: trigger
clippy::op_ref(needlessly taken reference of both operands) when a comparison operator's operands implementPartialOrdbut notOrd. Previously, the lint only fired if and only ifOrdwas implemented.