rust-lang / rust-lang/rust-clippy
redundant_locals incorrectly emitted when binding in new local scope for early drop
Open
Nobody has claimed this yet.
C-bug
I-false-positive
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
let (result_stream, threads) = {
let query = query; // ERROR
ringboard_sdk::search(
if regex {
Query::Regex(Regex::new(&query)?)
} else if ignore_case {
Query::PlainIgnoreCase(CaselessQuery::new(query).trim())
} else {
Query::Plain(query.as_bytes())
},
reader.clone(),
)
};
I'm rebinding an outside scope variable to get it to drop after starting the search.
Lint Name
redundant_locals
Reproducer
No response
Version
rustc 1.82.0-nightly (64ebd39da 2024-08-03)
binary: rustc
commit-hash: 64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b
commit-date: 2024-08-03
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0
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 at the redundant_locals lint entry point and use the Rust snippet as the regression case. Done means the inner-scope rebinding used for early drop no longer produces a redundant_locals diagnostic, with the focused lint test passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100