rust-lang / rust-lang/rust-clippy
reinitialization with let
Open
Nobody has claimed this yet.
- #11687 by @lengyijun — closed without merging
A-lint
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
If an assignment dominate all usages where it can reach, assignment can be replaced by a let bind, instead of overwrite
Advantage
- less
mut - like functional programming
- explicit dominance
- helpful in jumpping to definition in ide
Drawbacks
None (not sure)
Example
let mut x = "hello".to_string();
let mut y = vec![];
y.push(x);
x = "goodbye".to_string();
println!("{}", x);
Could be written as:
let mut x = "hello".to_string();
let mut y = vec![];
y.push(x);
let x = "goodbye".to_string();
println!("{}", x);
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 reviewing the issue's Rust examples and the linked pull request #11687 to understand the proposed reinitialization behavior. Determine the intended lint scope, its handling of dominance and later bindings, and the tests needed to establish when the transformation is valid; done means the behavior and acceptance criteria are agreed.
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
- Needs clarification
- Newbie friendliness
- 25/100