summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/panicking_unwrap.txt
blob: 1fbc245c8ec386ba87fdb7075e49c511a8fd5b02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
### What it does
Checks for calls of `unwrap[_err]()` that will always fail.

### Why is this bad?
If panicking is desired, an explicit `panic!()` should be used.

### Known problems
This lint only checks `if` conditions not assignments.
So something like `let x: Option<()> = None; x.unwrap();` will not be recognized.

### Example
```
if option.is_none() {
    do_something_with(option.unwrap())
}
```

This code will always panic. The if condition should probably be inverted.