summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/items_after_statements.txt
blob: 6fdfff50d20e40844dfd35f78c55b945b9af6661 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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"
}
```