rust-lang / rust-lang/rust-clippy
manual_range_contains misses non-literals
Open
Nobody has claimed this yet.
C-bug
I-false-negative
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Lint name: manual_range_contains
I tried this code:
fn main() {
let x = 4.0;
let y = 0.0;
let z = 5.0;
if y <= x && x <= z {
println!("Hello, world!");
}
}
I expected to see this happen: Warning: help: use: (y..=z).contains(&x)
Instead, this happened: No warning.
Meta
Rust version (rustc -Vv):
rustc 1.55.0 (c8dfcfe04 2021-09-06)
binary: rustc
commit-hash: c8dfcfe046a7680554bf4eb612bad840e7631c4b
commit-date: 2021-09-06
host: x86_64-unknown-linux-gnu
release: 1.55.0
LLVM version: 12.0.1
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 manual_range_contains lint entry point named in the issue and reproduce the reported Rust example. Compare its handling of literal and variable operands, then add coverage for the non-literal case and confirm the expected contains suggestion is emitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100