Description
The eq_op
lint has a quite large number of allow
s, ranking in "The most commonly ignored lints" (#5418), and it seems the number has largely increased because of the inclusion of the assert!
family (#6167). I've looked at some of the details and found the overwhelming majority was in test code to ensure they implemented functions and traits like PartialEq
correctly; here and here for example.
I'm not sure if I consider this case as a false positive, but legit supression at this scale doesn't seem right although no one except this comment reported this at the moment. However, disabling in test code altogether makes a new FN in case of unintensional eq_op
s. If Clippy don't do this, it means the intension of this lint is silence it in these tests at the smallest scale possible so it can catch other mistakes in test code.
I'd like to ask other people if trading off the FN for eliminating this FP (sort of) is worth or not though I'm in favour of disabling eq_op
in test code.
As a bonus, this can close #6635 nicely.
The implementation will probably be detecting #[test]
attriubtes so the minimal repro (?) would be:
#[test]
fn equality() {
let a = 42;
assert_eq!(a, a);
}
I expected to see this happen: no errors
Instead, this happened (with --all-targets
):
error: identical args used in this `assert_eq!` macro call
--> src/lib.rs:6:20
|
6 | assert_eq!(a, a);
| ^^^^
|
= note: `#[deny(clippy::eq_op)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op
Meta
cargo clippy -V
: clippy 0.1.51 (2fd73fa 2021-03-23)rustc -Vv
:rustc 1.51.0 (2fd73fabe 2021-03-23) binary: rustc commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0 commit-date: 2021-03-23 host: x86_64-unknown-linux-gnu release: 1.51.0 LLVM version: 11.0.1