summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/implicit_return.txt
blob: ee65a636b38c5aa4d2640074d7887bc82ee7b4f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
### What it does
Checks for missing return statements at the end of a block.

### Why is this bad?
Actually omitting the return keyword is idiomatic Rust code. Programmers
coming from other languages might prefer the expressiveness of `return`. It's possible to miss
the last returning statement because the only difference is a missing `;`. Especially in bigger
code with multiple return paths having a `return` keyword makes it easier to find the
corresponding statements.

### Example
```
fn foo(x: usize) -> usize {
    x
}
```
add return
```
fn foo(x: usize) -> usize {
    return x;
}
```