summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/shadow_unrelated.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/shadow_unrelated.txt')
-rw-r--r--src/tools/clippy/src/docs/shadow_unrelated.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/shadow_unrelated.txt b/src/tools/clippy/src/docs/shadow_unrelated.txt
new file mode 100644
index 000000000..436251c52
--- /dev/null
+++ b/src/tools/clippy/src/docs/shadow_unrelated.txt
@@ -0,0 +1,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
+``` \ No newline at end of file