]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/src/docs/items_after_statements.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / items_after_statements.txt
CommitLineData
f2b60f7d
FG
1### What it does
2Checks for items declared after some statement in a block.
3
4### Why is this bad?
5Items live for the entire scope they are declared
6in. But statements are processed in order. This might cause confusion as
7it's hard to figure out which item is meant in a statement.
8
9### Example
10```
11fn foo() {
12 println!("cake");
13}
14
15fn main() {
16 foo(); // prints "foo"
17 fn foo() {
18 println!("foo");
19 }
20 foo(); // prints "foo"
21}
22```
23
24Use instead:
25```
26fn foo() {
27 println!("cake");
28}
29
30fn main() {
31 fn foo() {
32 println!("foo");
33 }
34 foo(); // prints "foo"
35 foo(); // prints "foo"
36}
37```