closure upvars disable `unused_assignments` lint
Open
Nobody has claimed this yet.
A-lints
C-bug
L-false-negative
L-unused_variables
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
fn main() {
let mut overwritten = false;
let _ = || overwritten = true;
}
does not trigger any lints while
fn main() {
let mut overwritten = false;
if false {
overwritten = true;
}
}
results in
warning: variable `overwritten` is assigned to, but never used
--> src/main.rs:2:13
|
2 | let mut overwritten = false;
| ^^^^^^^^^^^
|
= note: consider using `_overwritten` instead
= note: `#[warn(unused_variables)]` on by default
The unused_variables and lint should look into nested closures here.
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
Reproduce the two Rust examples from the issue and compare the behavior of the unused_variables and unused_assignments lints around nested closures. Locate their compiler implementations and existing lint tests, then add coverage showing that captured assignments are diagnosed; done means the closure example emits the appropriate lint without regressing the conditional-assignment case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100