1 #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
3 clippy
::if_same_then_else
,
4 clippy
::branches_sharing_code
,
5 clippy
::unnecessary_literal_unwrap
8 fn test_complex_conditions() {
9 let x
: Result
<(), ()> = Ok(());
10 let y
: Result
<(), ()> = Ok(());
11 if x
.is_ok() && y
.is_err() {
14 //~^ ERROR: called `unwrap` on `x` after checking its variant with `is_ok`
17 //~^ ERROR: this call to `unwrap_err()` will always panic
20 //~^ ERROR: this call to `unwrap()` will always panic
23 //~^ ERROR: called `unwrap_err` on `y` after checking its variant with `is_err`
25 // not statically determinable whether any of the following will always succeed or always fail:
32 if x
.is_ok() || y
.is_ok() {
33 // not statically determinable whether any of the following will always succeed or always fail:
39 //~^ ERROR: this call to `unwrap()` will always panic
42 //~^ ERROR: called `unwrap_err` on `x` after checking its variant with `is_ok`
45 //~^ ERROR: this call to `unwrap()` will always panic
48 //~^ ERROR: called `unwrap_err` on `y` after checking its variant with `is_ok`
50 let z
: Result
<(), ()> = Ok(());
51 if x
.is_ok() && !(y
.is_ok() || z
.is_err()) {
54 //~^ ERROR: called `unwrap` on `x` after checking its variant with `is_ok`
57 //~^ ERROR: this call to `unwrap_err()` will always panic
60 //~^ ERROR: this call to `unwrap()` will always panic
63 //~^ ERROR: called `unwrap_err` on `y` after checking its variant with `is_ok`
66 //~^ ERROR: called `unwrap` on `z` after checking its variant with `is_err`
69 //~^ ERROR: this call to `unwrap_err()` will always panic
71 if x
.is_ok() || !(y
.is_ok() && z
.is_err()) {
72 // not statically determinable whether any of the following will always succeed or always fail:
79 //~^ ERROR: this call to `unwrap()` will always panic
82 //~^ ERROR: called `unwrap_err` on `x` after checking its variant with `is_ok`
85 //~^ ERROR: called `unwrap` on `y` after checking its variant with `is_ok`
88 //~^ ERROR: this call to `unwrap_err()` will always panic
91 //~^ ERROR: this call to `unwrap()` will always panic
94 //~^ ERROR: called `unwrap_err` on `z` after checking its variant with `is_err`