diff options
Diffstat (limited to 'src/tools/clippy/src/docs/panicking_unwrap.txt')
-rw-r--r-- | src/tools/clippy/src/docs/panicking_unwrap.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/panicking_unwrap.txt b/src/tools/clippy/src/docs/panicking_unwrap.txt new file mode 100644 index 000000000..1fbc245c8 --- /dev/null +++ b/src/tools/clippy/src/docs/panicking_unwrap.txt @@ -0,0 +1,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.
\ No newline at end of file |