@@ -12,8 +12,17 @@ note: the lint level is defined here
1212LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
1313 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
1414
15+ error: you checked before that `expect()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
16+ --> $DIR/simple_conditionals.rs:40:9
17+ |
18+ LL | if x.is_some() {
19+ | ----------- the check is happening here
20+ LL | x.unwrap(); // unnecessary
21+ LL | x.expect("an error message"); // unnecessary
22+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23+
1524error: this call to `unwrap()` will always panic
16- --> $DIR/simple_conditionals.rs:41 :9
25+ --> $DIR/simple_conditionals.rs:42 :9
1726 |
1827LL | if x.is_some() {
1928 | ----------- because of this check
@@ -27,16 +36,25 @@ note: the lint level is defined here
2736LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
2837 | ^^^^^^^^^^^^^^^^^^^^^^^^
2938
39+ error: this call to `expect()` will always panic
40+ --> $DIR/simple_conditionals.rs:43:9
41+ |
42+ LL | if x.is_some() {
43+ | ----------- because of this check
44+ ...
45+ LL | x.expect("an error message"); // will panic
46+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47+
3048error: this call to `unwrap()` will always panic
31- --> $DIR/simple_conditionals.rs:44 :9
49+ --> $DIR/simple_conditionals.rs:46 :9
3250 |
3351LL | if x.is_none() {
3452 | ----------- because of this check
3553LL | x.unwrap(); // will panic
3654 | ^^^^^^^^^^
3755
3856error: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
39- --> $DIR/simple_conditionals.rs:46 :9
57+ --> $DIR/simple_conditionals.rs:48 :9
4058 |
4159LL | if x.is_none() {
4260 | ----------- the check is happening here
@@ -58,33 +76,51 @@ LL | m!(x);
5876 = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
5977
6078error: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
61- --> $DIR/simple_conditionals.rs:54 :9
79+ --> $DIR/simple_conditionals.rs:56 :9
6280 |
6381LL | if x.is_ok() {
6482 | --------- the check is happening here
6583LL | x.unwrap(); // unnecessary
6684 | ^^^^^^^^^^
6785
86+ error: you checked before that `expect()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
87+ --> $DIR/simple_conditionals.rs:57:9
88+ |
89+ LL | if x.is_ok() {
90+ | --------- the check is happening here
91+ LL | x.unwrap(); // unnecessary
92+ LL | x.expect("an error message"); // unnecessary
93+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
94+
6895error: this call to `unwrap_err()` will always panic
69- --> $DIR/simple_conditionals.rs:55 :9
96+ --> $DIR/simple_conditionals.rs:58 :9
7097 |
7198LL | if x.is_ok() {
7299 | --------- because of this check
73- LL | x.unwrap(); // unnecessary
100+ ...
74101LL | x.unwrap_err(); // will panic
75102 | ^^^^^^^^^^^^^^
76103
77104error: this call to `unwrap()` will always panic
78- --> $DIR/simple_conditionals.rs:57 :9
105+ --> $DIR/simple_conditionals.rs:60 :9
79106 |
80107LL | if x.is_ok() {
81108 | --------- because of this check
82109...
83110LL | x.unwrap(); // will panic
84111 | ^^^^^^^^^^
85112
113+ error: this call to `expect()` will always panic
114+ --> $DIR/simple_conditionals.rs:61:9
115+ |
116+ LL | if x.is_ok() {
117+ | --------- because of this check
118+ ...
119+ LL | x.expect("an error message"); // will panic
120+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121+
86122error: you checked before that `unwrap_err()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
87- --> $DIR/simple_conditionals.rs:58 :9
123+ --> $DIR/simple_conditionals.rs:62 :9
88124 |
89125LL | if x.is_ok() {
90126 | --------- the check is happening here
@@ -93,15 +129,15 @@ LL | x.unwrap_err(); // unnecessary
93129 | ^^^^^^^^^^^^^^
94130
95131error: this call to `unwrap()` will always panic
96- --> $DIR/simple_conditionals.rs:61 :9
132+ --> $DIR/simple_conditionals.rs:65 :9
97133 |
98134LL | if x.is_err() {
99135 | ---------- because of this check
100136LL | x.unwrap(); // will panic
101137 | ^^^^^^^^^^
102138
103139error: you checked before that `unwrap_err()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
104- --> $DIR/simple_conditionals.rs:62 :9
140+ --> $DIR/simple_conditionals.rs:66 :9
105141 |
106142LL | if x.is_err() {
107143 | ---------- the check is happening here
@@ -110,7 +146,7 @@ LL | x.unwrap_err(); // unnecessary
110146 | ^^^^^^^^^^^^^^
111147
112148error: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
113- --> $DIR/simple_conditionals.rs:64 :9
149+ --> $DIR/simple_conditionals.rs:68 :9
114150 |
115151LL | if x.is_err() {
116152 | ---------- the check is happening here
@@ -119,13 +155,13 @@ LL | x.unwrap(); // unnecessary
119155 | ^^^^^^^^^^
120156
121157error: this call to `unwrap_err()` will always panic
122- --> $DIR/simple_conditionals.rs:65 :9
158+ --> $DIR/simple_conditionals.rs:69 :9
123159 |
124160LL | if x.is_err() {
125161 | ---------- because of this check
126162...
127163LL | x.unwrap_err(); // will panic
128164 | ^^^^^^^^^^^^^^
129165
130- error: aborting due to 13 previous errors
166+ error: aborting due to 17 previous errors
131167
0 commit comments