rust-lang / rust-lang/rust-clippy
false negative on clippy::filter_next when filter and next wraps map
Open
Nobody has claimed this yet.
C-bug
C-enhancement
E-medium
I-false-negative
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
False negative when filter and next is wrapped around a map.
There might be a few other methods like map that will have the same effect.
I tried this code:
v.windows(3)
.enumerate()
.filter(|(_, a)| a == &[true, false, true])
.map(|(v, _)| v + 1)
.next()
.unwrap()
I expected to see this happen: Clippy to suggest
v.windows(3)
.enumerate()
.find(|(_, a)| a == &[true, false, true])
.map(|(v, _)| v + 1)
.unwrap()
Instead, this happened: Nothing
Meta
cargo clippy -V: e.g. clippy 0.0.212 (1c389ff 2020-11-24)rustrustc -Vv:rustc 1.50.0-nightly (1c389ffef 2020-11-24) binary: rustc commit-hash: 1c389ffeff814726dec325f0f2b0c99107df2673 commit-date: 2020-11-24 host: x86_64-unknown-linux-gnu release: 1.50.0-nightly
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 reproducing the provided Rust snippet with cargo clippy using the reported toolchain details. Trace the filter_next lint's handling of filter, map, and next, then verify that the example produces the expected find-based suggestion rather than no diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100