1 #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
2 #![allow(clippy::if_same_then_else)]
4 fn test_complex_conditions() {
5 let x: Result<(), ()> = Ok(());
6 let y: Result<(), ()> = Ok(());
7 if x.is_ok() && y.is_err() {
8 x.unwrap(); // unnecessary
9 x.unwrap_err(); // will panic
10 y.unwrap(); // will panic
11 y.unwrap_err(); // unnecessary
13 // not statically determinable whether any of the following will always succeed or always fail:
20 if x.is_ok() || y.is_ok() {
21 // not statically determinable whether any of the following will always succeed or always fail:
25 x.unwrap(); // will panic
26 x.unwrap_err(); // unnecessary
27 y.unwrap(); // will panic
28 y.unwrap_err(); // unnecessary
30 let z: Result<(), ()> = Ok(());
31 if x.is_ok() && !(y.is_ok() || z.is_err()) {
32 x.unwrap(); // unnecessary
33 x.unwrap_err(); // will panic
34 y.unwrap(); // will panic
35 y.unwrap_err(); // unnecessary
36 z.unwrap(); // unnecessary
37 z.unwrap_err(); // will panic
39 if x.is_ok() || !(y.is_ok() && z.is_err()) {
40 // not statically determinable whether any of the following will always succeed or always fail:
45 x.unwrap(); // will panic
46 x.unwrap_err(); // unnecessary
47 y.unwrap(); // unnecessary
48 y.unwrap_err(); // will panic
49 z.unwrap(); // will panic
50 z.unwrap_err(); // unnecessary