summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/items_after_statements.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/src/docs/items_after_statements.txt37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/items_after_statements.txt b/src/tools/clippy/src/docs/items_after_statements.txt
new file mode 100644
index 000000000..6fdfff50d
--- /dev/null
+++ b/src/tools/clippy/src/docs/items_after_statements.txt
@@ -0,0 +1,37 @@
+### What it does
+Checks for items declared after some statement in a block.
+
+### Why is this bad?
+Items live for the entire scope they are declared
+in. But statements are processed in order. This might cause confusion as
+it's hard to figure out which item is meant in a statement.
+
+### Example
+```
+fn foo() {
+ println!("cake");
+}
+
+fn main() {
+ foo(); // prints "foo"
+ fn foo() {
+ println!("foo");
+ }
+ foo(); // prints "foo"
+}
+```
+
+Use instead:
+```
+fn foo() {
+ println!("cake");
+}
+
+fn main() {
+ fn foo() {
+ println!("foo");
+ }
+ foo(); // prints "foo"
+ foo(); // prints "foo"
+}
+``` \ No newline at end of file