rust-lang / rust-lang/rust-clippy

Shadowing an immutable binding to a mutable one

Open
#1,699 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint T-middle
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.