1 #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
2 #![allow(clippy::if_same_then_else)]
7 $a.unwrap(); // unnecessary
12 macro_rules! checks_in_param {
13 ($a:expr, $b:expr) => {
20 macro_rules! checks_unwrap {
21 ($a:expr, $b:expr) => {
28 macro_rules! checks_some {
29 ($a:expr, $b:expr) => {
39 x.unwrap(); // unnecessary
41 x.unwrap(); // will panic
44 x.unwrap(); // will panic
46 x.unwrap(); // unnecessary
49 checks_in_param!(x.is_some(), x.unwrap()); // ok
50 checks_unwrap!(x, x.unwrap()); // ok
51 checks_some!(x.is_some(), x); // ok
52 let mut x: Result<(), ()> = Ok(());
54 x.unwrap(); // unnecessary
55 x.unwrap_err(); // will panic
57 x.unwrap(); // will panic
58 x.unwrap_err(); // unnecessary
61 x.unwrap(); // will panic
62 x.unwrap_err(); // unnecessary
64 x.unwrap(); // unnecessary
65 x.unwrap_err(); // will panic
69 // not unnecessary because of mutation of x
70 // it will always panic but the lint is not smart enough to see this (it only
71 // checks if conditions).
75 // not unnecessary because of mutation of x
76 // it will always panic but the lint is not smart enough to see this (it
77 // only checks if conditions).
81 assert!(x.is_ok(), "{:?}", x.unwrap_err()); // ok, it's a common test pattern