@@ -12,8 +12,17 @@ note: the lint level is defined here
12
12
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
13
13
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
14
14
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
+
15
24
error: this call to `unwrap()` will always panic
16
- --> $DIR/simple_conditionals.rs:41 :9
25
+ --> $DIR/simple_conditionals.rs:42 :9
17
26
|
18
27
LL | if x.is_some() {
19
28
| ----------- because of this check
@@ -27,16 +36,25 @@ note: the lint level is defined here
27
36
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
28
37
| ^^^^^^^^^^^^^^^^^^^^^^^^
29
38
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
+
30
48
error: this call to `unwrap()` will always panic
31
- --> $DIR/simple_conditionals.rs:44 :9
49
+ --> $DIR/simple_conditionals.rs:46 :9
32
50
|
33
51
LL | if x.is_none() {
34
52
| ----------- because of this check
35
53
LL | x.unwrap(); // will panic
36
54
| ^^^^^^^^^^
37
55
38
56
error: 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
40
58
|
41
59
LL | if x.is_none() {
42
60
| ----------- the check is happening here
@@ -58,33 +76,51 @@ LL | m!(x);
58
76
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
59
77
60
78
error: 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
62
80
|
63
81
LL | if x.is_ok() {
64
82
| --------- the check is happening here
65
83
LL | x.unwrap(); // unnecessary
66
84
| ^^^^^^^^^^
67
85
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
+
68
95
error: this call to `unwrap_err()` will always panic
69
- --> $DIR/simple_conditionals.rs:55 :9
96
+ --> $DIR/simple_conditionals.rs:58 :9
70
97
|
71
98
LL | if x.is_ok() {
72
99
| --------- because of this check
73
- LL | x.unwrap(); // unnecessary
100
+ ...
74
101
LL | x.unwrap_err(); // will panic
75
102
| ^^^^^^^^^^^^^^
76
103
77
104
error: this call to `unwrap()` will always panic
78
- --> $DIR/simple_conditionals.rs:57 :9
105
+ --> $DIR/simple_conditionals.rs:60 :9
79
106
|
80
107
LL | if x.is_ok() {
81
108
| --------- because of this check
82
109
...
83
110
LL | x.unwrap(); // will panic
84
111
| ^^^^^^^^^^
85
112
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
+
86
122
error: 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
88
124
|
89
125
LL | if x.is_ok() {
90
126
| --------- the check is happening here
@@ -93,15 +129,15 @@ LL | x.unwrap_err(); // unnecessary
93
129
| ^^^^^^^^^^^^^^
94
130
95
131
error: this call to `unwrap()` will always panic
96
- --> $DIR/simple_conditionals.rs:61 :9
132
+ --> $DIR/simple_conditionals.rs:65 :9
97
133
|
98
134
LL | if x.is_err() {
99
135
| ---------- because of this check
100
136
LL | x.unwrap(); // will panic
101
137
| ^^^^^^^^^^
102
138
103
139
error: 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
105
141
|
106
142
LL | if x.is_err() {
107
143
| ---------- the check is happening here
@@ -110,7 +146,7 @@ LL | x.unwrap_err(); // unnecessary
110
146
| ^^^^^^^^^^^^^^
111
147
112
148
error: 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
114
150
|
115
151
LL | if x.is_err() {
116
152
| ---------- the check is happening here
@@ -119,13 +155,13 @@ LL | x.unwrap(); // unnecessary
119
155
| ^^^^^^^^^^
120
156
121
157
error: this call to `unwrap_err()` will always panic
122
- --> $DIR/simple_conditionals.rs:65 :9
158
+ --> $DIR/simple_conditionals.rs:69 :9
123
159
|
124
160
LL | if x.is_err() {
125
161
| ---------- because of this check
126
162
...
127
163
LL | x.unwrap_err(); // will panic
128
164
| ^^^^^^^^^^^^^^
129
165
130
- error: aborting due to 13 previous errors
166
+ error: aborting due to 17 previous errors
131
167
0 commit comments