]> git.lizzy.rs Git - rust.git/blob - src/docs/shadow_unrelated.txt
Add iter_kv_map lint
[rust.git] / src / docs / shadow_unrelated.txt
1 ### What it does
2 Checks for bindings that shadow other bindings already in
3 scope, either without an initialization or with one that does not even use
4 the original value.
5
6 ### Why is this bad?
7 Name shadowing can hurt readability, especially in
8 large code bases, because it is easy to lose track of the active binding at
9 any place in the code. This can be alleviated by either giving more specific
10 names to bindings or introducing more scopes to contain the bindings.
11
12 ### Example
13 ```
14 let x = y;
15 let x = z; // shadows the earlier binding
16 ```
17
18 Use instead:
19 ```
20 let x = y;
21 let w = z; // use different variable name
22 ```