rust-lang / rust-lang/rust-clippy
Expand float_cmp to structs with PartialEq
Open
Nobody has claimed this yet.
C-enhancement
good first issue
L-correctness
T-middle
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Example:
#[derive(PartialEq)]
struct Data {
v: f64,
}
fn main() {
let d1 = Data { v: 1.0 };
let d2 = Data { v: 2.0 };
// here should be a warning
println!("{}", d1 == d2);
}
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 by locating the existing float_cmp lint and its tests in the rust-clippy repository. Trace how direct floating-point comparisons are detected, then determine how a derived PartialEq implementation on a struct containing f64 should be handled. Done means the example produces the intended warning and the relevant lint tests cover the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100