]> git.lizzy.rs Git - rust.git/blob - tests/ui/matches.stderr
Merge pull request #2433 from kimsnj/matches_sugg
[rust.git] / tests / ui / matches.stderr
1 error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
2   --> $DIR/matches.rs:26:5
3    |
4 26 | /     match ExprNode::Butterflies {
5 27 | |         ExprNode::ExprAddrOf => Some(&NODE),
6 28 | |         _ => { let x = 5; None },
7 29 | |     }
8    | |_____^ help: try this: `if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None }`
9    |
10    = note: `-D single-match-else` implied by `-D warnings`
11
12 error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
13   --> $DIR/matches.rs:35:5
14    |
15 35 | /     match x {
16 36 | |         Some(y) => { println!("{:?}", y); }
17 37 | |         _ => ()
18 38 | |     };
19    | |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y); }`
20    |
21    = note: `-D single-match` implied by `-D warnings`
22
23 error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
24   --> $DIR/matches.rs:41:5
25    |
26 41 | /     match z {
27 42 | |         (2...3, 7...9) => dummy(),
28 43 | |         _ => {}
29 44 | |     };
30    | |_____^ help: try this: `if let (2...3, 7...9) = z { dummy() }`
31
32 error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
33   --> $DIR/matches.rs:63:5
34    |
35 63 | /     match x {
36 64 | |         Some(y) => dummy(),
37 65 | |         None => ()
38 66 | |     };
39    | |_____^ help: try this: `if let Some(y) = x { dummy() }`
40
41 error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
42   --> $DIR/matches.rs:68:5
43    |
44 68 | /     match y {
45 69 | |         Ok(y) => dummy(),
46 70 | |         Err(..) => ()
47 71 | |     };
48    | |_____^ help: try this: `if let Ok(y) = y { dummy() }`
49
50 error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
51   --> $DIR/matches.rs:75:5
52    |
53 75 | /     match c {
54 76 | |         Cow::Borrowed(..) => dummy(),
55 77 | |         Cow::Owned(..) => (),
56 78 | |     };
57    | |_____^ help: try this: `if let Cow::Borrowed(..) = c { dummy() }`
58
59 error: you seem to be trying to match on a boolean expression
60   --> $DIR/matches.rs:96:5
61    |
62 96 | /     match test {
63 97 | |         true => 0,
64 98 | |         false => 42,
65 99 | |     };
66    | |_____^ help: consider using an if/else expression: `if test { 0 } else { 42 }`
67    |
68    = note: `-D match-bool` implied by `-D warnings`
69
70 error: you seem to be trying to match on a boolean expression
71    --> $DIR/matches.rs:102:5
72     |
73 102 | /     match option == 1 {
74 103 | |         true => 1,
75 104 | |         false => 0,
76 105 | |     };
77     | |_____^ help: consider using an if/else expression: `if option == 1 { 1 } else { 0 }`
78
79 error: you seem to be trying to match on a boolean expression
80    --> $DIR/matches.rs:107:5
81     |
82 107 | /     match test {
83 108 | |         true => (),
84 109 | |         false => { println!("Noooo!"); }
85 110 | |     };
86     | |_____^ help: consider using an if/else expression: `if !test { println!("Noooo!"); }`
87
88 error: you seem to be trying to match on a boolean expression
89    --> $DIR/matches.rs:112:5
90     |
91 112 | /     match test {
92 113 | |         false => { println!("Noooo!"); }
93 114 | |         _ => (),
94 115 | |     };
95     | |_____^ help: consider using an if/else expression: `if !test { println!("Noooo!"); }`
96
97 error: you seem to be trying to match on a boolean expression
98    --> $DIR/matches.rs:117:5
99     |
100 117 | /     match test && test {
101 118 | |         false => { println!("Noooo!"); }
102 119 | |         _ => (),
103 120 | |     };
104     | |_____^ help: consider using an if/else expression: `if !(test && test) { println!("Noooo!"); }`
105
106 error: equal expressions as operands to `&&`
107    --> $DIR/matches.rs:117:11
108     |
109 117 |     match test && test {
110     |           ^^^^^^^^^^^^
111     |
112     = note: `-D eq-op` implied by `-D warnings`
113
114 error: you seem to be trying to match on a boolean expression
115    --> $DIR/matches.rs:122:5
116     |
117 122 | /     match test {
118 123 | |         false => { println!("Noooo!"); }
119 124 | |         true => { println!("Yes!"); }
120 125 | |     };
121     | |_____^ help: consider using an if/else expression: `if test { println!("Yes!"); } else { println!("Noooo!"); }`
122
123 error: you don't need to add `&` to all patterns
124    --> $DIR/matches.rs:138:9
125     |
126 138 | /         match v {
127 139 | |             &Some(v) => println!("{:?}", v),
128 140 | |             &None => println!("none"),
129 141 | |         }
130     | |_________^
131     |
132     = note: `-D match-ref-pats` implied by `-D warnings`
133 help: instead of prefixing all patterns with `&`, you can dereference the expression
134     |
135 138 |         match *v {
136 139 |             Some(v) => println!("{:?}", v),
137 140 |             None => println!("none"),
138     |
139
140 error: you don't need to add `&` to all patterns
141    --> $DIR/matches.rs:148:5
142     |
143 148 | /     match tup {
144 149 | |         &(v, 1) => println!("{}", v),
145 150 | |         _ => println!("none"),
146 151 | |     }
147     | |_____^
148 help: instead of prefixing all patterns with `&`, you can dereference the expression
149     |
150 148 |     match *tup {
151 149 |         (v, 1) => println!("{}", v),
152     |
153
154 error: you don't need to add `&` to both the expression and the patterns
155    --> $DIR/matches.rs:154:5
156     |
157 154 | /     match &w {
158 155 | |         &Some(v) => println!("{:?}", v),
159 156 | |         &None => println!("none"),
160 157 | |     }
161     | |_____^
162 help: try
163     |
164 154 |     match w {
165 155 |         Some(v) => println!("{:?}", v),
166 156 |         None => println!("none"),
167     |
168
169 error: you don't need to add `&` to all patterns
170    --> $DIR/matches.rs:165:5
171     |
172 165 | /     if let &None = a {
173 166 | |         println!("none");
174 167 | |     }
175     | |_____^
176 help: instead of prefixing all patterns with `&`, you can dereference the expression
177     |
178 165 |     if let None = *a {
179     |
180
181 error: you don't need to add `&` to both the expression and the patterns
182    --> $DIR/matches.rs:170:5
183     |
184 170 | /     if let &None = &b {
185 171 | |         println!("none");
186 172 | |     }
187     | |_____^
188 help: try
189     |
190 170 |     if let None = b {
191     |
192
193 error: some ranges overlap
194    --> $DIR/matches.rs:179:9
195     |
196 179 |         0 ... 10 => println!("0 ... 10"),
197     |         ^^^^^^^^
198     |
199     = note: `-D match-overlapping-arm` implied by `-D warnings`
200 note: overlaps with this
201    --> $DIR/matches.rs:180:9
202     |
203 180 |         0 ... 11 => println!("0 ... 11"),
204     |         ^^^^^^^^
205
206 error: some ranges overlap
207    --> $DIR/matches.rs:185:9
208     |
209 185 |         0 ... 5 => println!("0 ... 5"),
210     |         ^^^^^^^
211     |
212 note: overlaps with this
213    --> $DIR/matches.rs:187:9
214     |
215 187 |         FOO ... 11 => println!("0 ... 11"),
216     |         ^^^^^^^^^^
217
218 error: some ranges overlap
219    --> $DIR/matches.rs:193:9
220     |
221 193 |         0 ... 5 => println!("0 ... 5"),
222     |         ^^^^^^^
223     |
224 note: overlaps with this
225    --> $DIR/matches.rs:192:9
226     |
227 192 |         2 => println!("2"),
228     |         ^
229
230 error: some ranges overlap
231    --> $DIR/matches.rs:199:9
232     |
233 199 |         0 ... 2 => println!("0 ... 2"),
234     |         ^^^^^^^
235     |
236 note: overlaps with this
237    --> $DIR/matches.rs:198:9
238     |
239 198 |         2 => println!("2"),
240     |         ^
241
242 error: some ranges overlap
243    --> $DIR/matches.rs:222:9
244     |
245 222 |         0 .. 11 => println!("0 .. 11"),
246     |         ^^^^^^^
247     |
248 note: overlaps with this
249    --> $DIR/matches.rs:223:9
250     |
251 223 |         0 ... 11 => println!("0 ... 11"),
252     |         ^^^^^^^^
253
254 error: Err(_) will match all errors, maybe not a good idea
255    --> $DIR/matches.rs:240:9
256     |
257 240 |         Err(_) => panic!("err")
258     |         ^^^^^^
259     |
260     = note: `-D match-wild-err-arm` implied by `-D warnings`
261     = note: to remove this warning, match each error seperately or use unreachable macro
262
263 error: this `match` has identical arm bodies
264    --> $DIR/matches.rs:239:18
265     |
266 239 |         Ok(_) => println!("ok"),
267     |                  ^^^^^^^^^^^^^^
268     |
269     = note: `-D match-same-arms` implied by `-D warnings`
270 note: same as this
271    --> $DIR/matches.rs:238:18
272     |
273 238 |         Ok(3) => println!("ok"),
274     |                  ^^^^^^^^^^^^^^
275 note: consider refactoring into `Ok(3) | Ok(_)`
276    --> $DIR/matches.rs:238:18
277     |
278 238 |         Ok(3) => println!("ok"),
279     |                  ^^^^^^^^^^^^^^
280     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
281
282 error: Err(_) will match all errors, maybe not a good idea
283    --> $DIR/matches.rs:246:9
284     |
285 246 |         Err(_) => {panic!()}
286     |         ^^^^^^
287     |
288     = note: to remove this warning, match each error seperately or use unreachable macro
289
290 error: this `match` has identical arm bodies
291    --> $DIR/matches.rs:245:18
292     |
293 245 |         Ok(_) => println!("ok"),
294     |                  ^^^^^^^^^^^^^^
295     |
296 note: same as this
297    --> $DIR/matches.rs:244:18
298     |
299 244 |         Ok(3) => println!("ok"),
300     |                  ^^^^^^^^^^^^^^
301 note: consider refactoring into `Ok(3) | Ok(_)`
302    --> $DIR/matches.rs:244:18
303     |
304 244 |         Ok(3) => println!("ok"),
305     |                  ^^^^^^^^^^^^^^
306     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
307
308 error: Err(_) will match all errors, maybe not a good idea
309    --> $DIR/matches.rs:252:9
310     |
311 252 |         Err(_) => {panic!();}
312     |         ^^^^^^
313     |
314     = note: to remove this warning, match each error seperately or use unreachable macro
315
316 error: this `match` has identical arm bodies
317    --> $DIR/matches.rs:251:18
318     |
319 251 |         Ok(_) => println!("ok"),
320     |                  ^^^^^^^^^^^^^^
321     |
322 note: same as this
323    --> $DIR/matches.rs:250:18
324     |
325 250 |         Ok(3) => println!("ok"),
326     |                  ^^^^^^^^^^^^^^
327 note: consider refactoring into `Ok(3) | Ok(_)`
328    --> $DIR/matches.rs:250:18
329     |
330 250 |         Ok(3) => println!("ok"),
331     |                  ^^^^^^^^^^^^^^
332     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
333
334 error: this `match` has identical arm bodies
335    --> $DIR/matches.rs:258:18
336     |
337 258 |         Ok(_) => println!("ok"),
338     |                  ^^^^^^^^^^^^^^
339     |
340 note: same as this
341    --> $DIR/matches.rs:257:18
342     |
343 257 |         Ok(3) => println!("ok"),
344     |                  ^^^^^^^^^^^^^^
345 note: consider refactoring into `Ok(3) | Ok(_)`
346    --> $DIR/matches.rs:257:18
347     |
348 257 |         Ok(3) => println!("ok"),
349     |                  ^^^^^^^^^^^^^^
350     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
351
352 error: this `match` has identical arm bodies
353    --> $DIR/matches.rs:265:18
354     |
355 265 |         Ok(_) => println!("ok"),
356     |                  ^^^^^^^^^^^^^^
357     |
358 note: same as this
359    --> $DIR/matches.rs:264:18
360     |
361 264 |         Ok(3) => println!("ok"),
362     |                  ^^^^^^^^^^^^^^
363 note: consider refactoring into `Ok(3) | Ok(_)`
364    --> $DIR/matches.rs:264:18
365     |
366 264 |         Ok(3) => println!("ok"),
367     |                  ^^^^^^^^^^^^^^
368     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
369
370 error: this `match` has identical arm bodies
371    --> $DIR/matches.rs:271:18
372     |
373 271 |         Ok(_) => println!("ok"),
374     |                  ^^^^^^^^^^^^^^
375     |
376 note: same as this
377    --> $DIR/matches.rs:270:18
378     |
379 270 |         Ok(3) => println!("ok"),
380     |                  ^^^^^^^^^^^^^^
381 note: consider refactoring into `Ok(3) | Ok(_)`
382    --> $DIR/matches.rs:270:18
383     |
384 270 |         Ok(3) => println!("ok"),
385     |                  ^^^^^^^^^^^^^^
386     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
387
388 error: this `match` has identical arm bodies
389    --> $DIR/matches.rs:277:18
390     |
391 277 |         Ok(_) => println!("ok"),
392     |                  ^^^^^^^^^^^^^^
393     |
394 note: same as this
395    --> $DIR/matches.rs:276:18
396     |
397 276 |         Ok(3) => println!("ok"),
398     |                  ^^^^^^^^^^^^^^
399 note: consider refactoring into `Ok(3) | Ok(_)`
400    --> $DIR/matches.rs:276:18
401     |
402 276 |         Ok(3) => println!("ok"),
403     |                  ^^^^^^^^^^^^^^
404     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
405
406 error: this `match` has identical arm bodies
407    --> $DIR/matches.rs:298:29
408     |
409 298 |         (Ok(_), Some(x)) => println!("ok {}", x),
410     |                             ^^^^^^^^^^^^^^^^^^^^
411     |
412 note: same as this
413    --> $DIR/matches.rs:297:29
414     |
415 297 |         (Ok(x), Some(_)) => println!("ok {}", x),
416     |                             ^^^^^^^^^^^^^^^^^^^^
417 note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))`
418    --> $DIR/matches.rs:297:29
419     |
420 297 |         (Ok(x), Some(_)) => println!("ok {}", x),
421     |                             ^^^^^^^^^^^^^^^^^^^^
422     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
423
424 error: this `match` has identical arm bodies
425    --> $DIR/matches.rs:313:18
426     |
427 313 |         Ok(_) => println!("ok"),
428     |                  ^^^^^^^^^^^^^^
429     |
430 note: same as this
431    --> $DIR/matches.rs:312:18
432     |
433 312 |         Ok(3) => println!("ok"),
434     |                  ^^^^^^^^^^^^^^
435 note: consider refactoring into `Ok(3) | Ok(_)`
436    --> $DIR/matches.rs:312:18
437     |
438 312 |         Ok(3) => println!("ok"),
439     |                  ^^^^^^^^^^^^^^
440     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
441
442 error: use as_ref() instead
443    --> $DIR/matches.rs:320:33
444     |
445 320 |       let borrowed: Option<&()> = match owned {
446     |  _________________________________^
447 321 | |         None => None,
448 322 | |         Some(ref v) => Some(v),
449 323 | |     };
450     | |_____^ help: try this: `owned.as_ref()`
451     |
452     = note: `-D match-as-ref` implied by `-D warnings`
453
454 error: use as_mut() instead
455    --> $DIR/matches.rs:326:39
456     |
457 326 |       let borrow_mut: Option<&mut ()> = match mut_owned {
458     |  _______________________________________^
459 327 | |         None => None,
460 328 | |         Some(ref mut v) => Some(v),
461 329 | |     };
462     | |_____^ help: try this: `mut_owned.as_mut()`
463
464 error: aborting due to 37 previous errors
465