rust-lang / rust-lang/rust-clippy
derive_partial_eq_without_eq triggers for test-only PartialEq derives
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
The derive_partial_eq_without_eq lint triggers on #[cfg_attr(test, derive(PartialEq))], I think it shouldn't.
Lint Name
derive_partial_eq_without_eq
Reproducer
I tried this code:
#[cfg_attr(test, derive(PartialEq))]
pub struct Foo {}
I saw this happen with cargo clippy --tests:
warning: you are deriving `PartialEq` and can implement `Eq`
--> src/lib.rs:1:25
|
1 | #[cfg_attr(test, derive(PartialEq))]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
= note: `#[warn(clippy::derive_partial_eq_without_eq)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
I expected to see this happen: no warnings
Version
rustc 1.63.0-nightly (5750a6aa2 2022-06-20)
binary: rustc
commit-hash: 5750a6aa2777382bf421b726f234da23f990a953
commit-date: 2022-06-20
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.5
Additional Labels
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer in src/lib.rs and run cargo clippy --tests to confirm how derive_partial_eq_without_eq handles #[cfg_attr(test, derive(PartialEq))]. Trace the lint's handling of test-only derives and add or update coverage for this case. Done means cargo clippy --tests emits no warning for the test-only PartialEq derive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100