rust-lang / rust-lang/rust-clippy
Shadowing an immutable binding to a mutable one
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
In Rust it is possible to shadow a binding to some data, and as part of that, the binding can also be freely changed from immutable to mutable and vice versa. Shadowing that goes from mutable bindings to immutable bindings are good to have, since they allow you to do some amount of mutation before locking the data down. However, shadowing that goes from immutable bindings to mutable bindings are less useful as they hurt readability (an immutable binding cannot be assumed to remain immutable at any point).
A lint against cases of shadowing used to change a binding from immutable to mutable would thus be nice :)
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 requested lint behavior in this issue and existing Clippy lint conventions. Define which shadowing cases count as changing an immutable binding to mutable, then identify the relevant lint implementation and test locations. Done means the intended cases are diagnosed without incorrectly flagging other shadowing patterns, with regression coverage.
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
- 25/100