rust-lang / rust-lang/rust-clippy
Lint variable only ever assigned a single value
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
In both the rust source and the rustfmt source I encountered code of the sort
let first = false;
for x in y {
if first {
first = false;
// do some logic
}
// do some logic
}
If a variable never gets a mutable reference taken to and all assignments assign the same value, we should have a correctness lint tell the user they are doing something that makes no sense in any program.
This is probably easiest implemented as an MIR lint
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
Review the Rust source and rustfmt source examples described in the issue, then investigate the MIR lint entry points. Define how to detect variables whose assignments always use the same value and how the correctness lint should report them; done means the behavior is covered by appropriate lint tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100