]> git.lizzy.rs Git - rust.git/blob - src/docs/shadow_reuse.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / shadow_reuse.txt
1 ### What it does
2 Checks for bindings that shadow other bindings already in
3 scope, while reusing the original value.
4
5 ### Why is this bad?
6 Not too much, in fact it's a common pattern in Rust
7 code. Still, some argue that name shadowing like this hurts readability,
8 because a value may be bound to different things depending on position in
9 the code.
10
11 ### Example
12 ```
13 let x = 2;
14 let x = x + 1;
15 ```
16 use different variable name:
17 ```
18 let x = 2;
19 let y = x + 1;
20 ```