summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/shadow_unrelated.txt
blob: 436251c520a9810848ffd831a446ab565483dacd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
### What it does
Checks for bindings that shadow other bindings already in
scope, either without an initialization or with one that does not even use
the original value.

### Why is this bad?
Name shadowing can hurt readability, especially in
large code bases, because it is easy to lose track of the active binding at
any place in the code. This can be alleviated by either giving more specific
names to bindings or introducing more scopes to contain the bindings.

### Example
```
let x = y;
let x = z; // shadows the earlier binding
```

Use instead:
```
let x = y;
let w = z; // use different variable name
```