1
1
error: this block may be rewritten with the `?` operator
2
- --> tests/ui/question_mark.rs:7 :5
2
+ --> tests/ui/question_mark.rs:9 :5
3
3
|
4
4
LL | / if a.is_none() {
5
5
LL | |
@@ -11,7 +11,7 @@ LL | | }
11
11
= help: to override `-D warnings` add `#[allow(clippy::question_mark)]`
12
12
13
13
error: this block may be rewritten with the `?` operator
14
- --> tests/ui/question_mark.rs:53 :9
14
+ --> tests/ui/question_mark.rs:55 :9
15
15
|
16
16
LL | / if (self.opt).is_none() {
17
17
LL | |
@@ -20,7 +20,7 @@ LL | | }
20
20
| |_________^ help: replace it with: `(self.opt)?;`
21
21
22
22
error: this block may be rewritten with the `?` operator
23
- --> tests/ui/question_mark.rs:58 :9
23
+ --> tests/ui/question_mark.rs:60 :9
24
24
|
25
25
LL | / if self.opt.is_none() {
26
26
LL | |
@@ -29,7 +29,7 @@ LL | | }
29
29
| |_________^ help: replace it with: `self.opt?;`
30
30
31
31
error: this block may be rewritten with the `?` operator
32
- --> tests/ui/question_mark.rs:63 :17
32
+ --> tests/ui/question_mark.rs:65 :17
33
33
|
34
34
LL | let _ = if self.opt.is_none() {
35
35
| _________________^
@@ -41,7 +41,7 @@ LL | | };
41
41
| |_________^ help: replace it with: `Some(self.opt?)`
42
42
43
43
error: this block may be rewritten with the `?` operator
44
- --> tests/ui/question_mark.rs:70 :17
44
+ --> tests/ui/question_mark.rs:72 :17
45
45
|
46
46
LL | let _ = if let Some(x) = self.opt {
47
47
| _________________^
@@ -53,7 +53,7 @@ LL | | };
53
53
| |_________^ help: replace it with: `self.opt?`
54
54
55
55
error: this block may be rewritten with the `?` operator
56
- --> tests/ui/question_mark.rs:88 :9
56
+ --> tests/ui/question_mark.rs:90 :9
57
57
|
58
58
LL | / if self.opt.is_none() {
59
59
LL | |
@@ -62,7 +62,7 @@ LL | | }
62
62
| |_________^ help: replace it with: `self.opt.as_ref()?;`
63
63
64
64
error: this block may be rewritten with the `?` operator
65
- --> tests/ui/question_mark.rs:97 :9
65
+ --> tests/ui/question_mark.rs:99 :9
66
66
|
67
67
LL | / if self.opt.is_none() {
68
68
LL | |
@@ -71,7 +71,7 @@ LL | | }
71
71
| |_________^ help: replace it with: `self.opt.as_ref()?;`
72
72
73
73
error: this block may be rewritten with the `?` operator
74
- --> tests/ui/question_mark.rs:106 :9
74
+ --> tests/ui/question_mark.rs:108 :9
75
75
|
76
76
LL | / if self.opt.is_none() {
77
77
LL | |
@@ -80,7 +80,7 @@ LL | | }
80
80
| |_________^ help: replace it with: `self.opt.as_ref()?;`
81
81
82
82
error: this block may be rewritten with the `?` operator
83
- --> tests/ui/question_mark.rs:114 :26
83
+ --> tests/ui/question_mark.rs:116 :26
84
84
|
85
85
LL | let v: &Vec<_> = if let Some(ref v) = self.opt {
86
86
| __________________________^
@@ -92,7 +92,7 @@ LL | | };
92
92
| |_________^ help: replace it with: `self.opt.as_ref()?`
93
93
94
94
error: this block may be rewritten with the `?` operator
95
- --> tests/ui/question_mark.rs:125 :17
95
+ --> tests/ui/question_mark.rs:127 :17
96
96
|
97
97
LL | let v = if let Some(v) = self.opt {
98
98
| _________________^
@@ -104,7 +104,7 @@ LL | | };
104
104
| |_________^ help: replace it with: `self.opt?`
105
105
106
106
error: this block may be rewritten with the `?` operator
107
- --> tests/ui/question_mark.rs:147 :5
107
+ --> tests/ui/question_mark.rs:149 :5
108
108
|
109
109
LL | / if f().is_none() {
110
110
LL | |
@@ -113,7 +113,7 @@ LL | | }
113
113
| |_____^ help: replace it with: `f()?;`
114
114
115
115
error: this `match` expression can be replaced with `?`
116
- --> tests/ui/question_mark.rs:152 :16
116
+ --> tests/ui/question_mark.rs:154 :16
117
117
|
118
118
LL | let _val = match f() {
119
119
| ________________^
@@ -124,7 +124,7 @@ LL | | };
124
124
| |_____^ help: try instead: `f()?`
125
125
126
126
error: this `match` expression can be replaced with `?`
127
- --> tests/ui/question_mark.rs:163 :5
127
+ --> tests/ui/question_mark.rs:165 :5
128
128
|
129
129
LL | / match f() {
130
130
LL | |
@@ -134,7 +134,7 @@ LL | | };
134
134
| |_____^ help: try instead: `f()?`
135
135
136
136
error: this `match` expression can be replaced with `?`
137
- --> tests/ui/question_mark.rs:169 :5
137
+ --> tests/ui/question_mark.rs:171 :5
138
138
|
139
139
LL | / match opt_none!() {
140
140
LL | |
@@ -144,13 +144,13 @@ LL | | };
144
144
| |_____^ help: try instead: `opt_none!()?`
145
145
146
146
error: this block may be rewritten with the `?` operator
147
- --> tests/ui/question_mark.rs:196 :13
147
+ --> tests/ui/question_mark.rs:198 :13
148
148
|
149
149
LL | let _ = if let Ok(x) = x { x } else { return x };
150
150
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x?`
151
151
152
152
error: this block may be rewritten with the `?` operator
153
- --> tests/ui/question_mark.rs:199 :5
153
+ --> tests/ui/question_mark.rs:201 :5
154
154
|
155
155
LL | / if x.is_err() {
156
156
LL | |
@@ -159,7 +159,7 @@ LL | | }
159
159
| |_____^ help: replace it with: `x?;`
160
160
161
161
error: this `match` expression can be replaced with `?`
162
- --> tests/ui/question_mark.rs:204 :16
162
+ --> tests/ui/question_mark.rs:206 :16
163
163
|
164
164
LL | let _val = match func_returning_result() {
165
165
| ________________^
@@ -170,7 +170,7 @@ LL | | };
170
170
| |_____^ help: try instead: `func_returning_result()?`
171
171
172
172
error: this `match` expression can be replaced with `?`
173
- --> tests/ui/question_mark.rs:210 :5
173
+ --> tests/ui/question_mark.rs:212 :5
174
174
|
175
175
LL | / match func_returning_result() {
176
176
LL | |
@@ -180,7 +180,7 @@ LL | | };
180
180
| |_____^ help: try instead: `func_returning_result()?`
181
181
182
182
error: this block may be rewritten with the `?` operator
183
- --> tests/ui/question_mark.rs:302 :5
183
+ --> tests/ui/question_mark.rs:304 :5
184
184
|
185
185
LL | / if let Err(err) = func_returning_result() {
186
186
LL | |
@@ -189,7 +189,7 @@ LL | | }
189
189
| |_____^ help: replace it with: `func_returning_result()?;`
190
190
191
191
error: this block may be rewritten with the `?` operator
192
- --> tests/ui/question_mark.rs:310 :5
192
+ --> tests/ui/question_mark.rs:312 :5
193
193
|
194
194
LL | / if let Err(err) = func_returning_result() {
195
195
LL | |
@@ -198,7 +198,7 @@ LL | | }
198
198
| |_____^ help: replace it with: `func_returning_result()?;`
199
199
200
200
error: this block may be rewritten with the `?` operator
201
- --> tests/ui/question_mark.rs:388 :13
201
+ --> tests/ui/question_mark.rs:390 :13
202
202
|
203
203
LL | / if a.is_none() {
204
204
LL | |
@@ -208,55 +208,55 @@ LL | | }
208
208
| |_____________^ help: replace it with: `a?;`
209
209
210
210
error: this `let...else` may be rewritten with the `?` operator
211
- --> tests/ui/question_mark.rs:449 :5
211
+ --> tests/ui/question_mark.rs:451 :5
212
212
|
213
213
LL | / let Some(v) = bar.foo.owned.clone() else {
214
214
LL | | return None;
215
215
LL | | };
216
216
| |______^ help: replace it with: `let v = bar.foo.owned.clone()?;`
217
217
218
218
error: this `let...else` may be rewritten with the `?` operator
219
- --> tests/ui/question_mark.rs:464 :5
219
+ --> tests/ui/question_mark.rs:466 :5
220
220
|
221
221
LL | / let Some(ref x) = foo.opt_x else {
222
222
LL | | return None;
223
223
LL | | };
224
224
| |______^ help: replace it with: `let x = foo.opt_x.as_ref()?;`
225
225
226
226
error: this `let...else` may be rewritten with the `?` operator
227
- --> tests/ui/question_mark.rs:474 :5
227
+ --> tests/ui/question_mark.rs:476 :5
228
228
|
229
229
LL | / let Some(ref mut x) = foo.opt_x else {
230
230
LL | | return None;
231
231
LL | | };
232
232
| |______^ help: replace it with: `let x = foo.opt_x.as_mut()?;`
233
233
234
234
error: this `let...else` may be rewritten with the `?` operator
235
- --> tests/ui/question_mark.rs:485 :5
235
+ --> tests/ui/question_mark.rs:487 :5
236
236
|
237
237
LL | / let Some(ref x @ ref y) = foo.opt_x else {
238
238
LL | | return None;
239
239
LL | | };
240
240
| |______^ help: replace it with: `let x @ y = foo.opt_x.as_ref()?;`
241
241
242
242
error: this `let...else` may be rewritten with the `?` operator
243
- --> tests/ui/question_mark.rs:489 :5
243
+ --> tests/ui/question_mark.rs:491 :5
244
244
|
245
245
LL | / let Some(ref x @ WrapperStructWithString(_)) = bar else {
246
246
LL | | return None;
247
247
LL | | };
248
248
| |______^ help: replace it with: `let x @ &WrapperStructWithString(_) = bar.as_ref()?;`
249
249
250
250
error: this `let...else` may be rewritten with the `?` operator
251
- --> tests/ui/question_mark.rs:493 :5
251
+ --> tests/ui/question_mark.rs:495 :5
252
252
|
253
253
LL | / let Some(ref mut x @ WrapperStructWithString(_)) = bar else {
254
254
LL | | return None;
255
255
LL | | };
256
256
| |______^ help: replace it with: `let x @ &mut WrapperStructWithString(_) = bar.as_mut()?;`
257
257
258
258
error: this block may be rewritten with the `?` operator
259
- --> tests/ui/question_mark.rs:515 :5
259
+ --> tests/ui/question_mark.rs:517 :5
260
260
|
261
261
LL | / if arg.is_none() {
262
262
LL | |
@@ -265,7 +265,7 @@ LL | | }
265
265
| |_____^ help: replace it with: `arg?;`
266
266
267
267
error: this `match` expression can be replaced with `?`
268
- --> tests/ui/question_mark.rs:519 :15
268
+ --> tests/ui/question_mark.rs:521 :15
269
269
|
270
270
LL | let val = match arg {
271
271
| _______________^
@@ -275,5 +275,13 @@ LL | | None => return None,
275
275
LL | | };
276
276
| |_____^ help: try instead: `arg?`
277
277
278
- error: aborting due to 29 previous errors
278
+ error: this `let...else` may be rewritten with the `?` operator
279
+ --> tests/ui/question_mark.rs:531:5
280
+ |
281
+ LL | / let Some(a) = *a.lock() else {
282
+ LL | | return None;
283
+ LL | | };
284
+ | |______^ help: replace it with: `let a = (*a.lock())?;`
285
+
286
+ error: aborting due to 30 previous errors
279
287
0 commit comments