]> git.lizzy.rs Git - rust.git/blob - tests/ui/matches.stderr
Merge pull request #2984 from flip1995/single_char_pattern
[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:21:5
3    |
4 21 | /     match ExprNode::Butterflies {
5 22 | |         ExprNode::ExprAddrOf => Some(&NODE),
6 23 | |         _ => { let x = 5; None },
7 24 | |     }
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 don't need to add `&` to all patterns
13   --> $DIR/matches.rs:30:9
14    |
15 30 | /         match v {
16 31 | |             &Some(v) => println!("{:?}", v),
17 32 | |             &None => println!("none"),
18 33 | |         }
19    | |_________^
20    |
21    = note: `-D match-ref-pats` implied by `-D warnings`
22 help: instead of prefixing all patterns with `&`, you can dereference the expression
23    |
24 30 |         match *v {
25 31 |             Some(v) => println!("{:?}", v),
26 32 |             None => println!("none"),
27    |
28
29 error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
30   --> $DIR/matches.rs:40:5
31    |
32 40 | /     match tup {
33 41 | |         &(v, 1) => println!("{}", v),
34 42 | |         _ => println!("none"),
35 43 | |     }
36    | |_____^
37 help: try this
38    |
39 40 |     if let &(v, 1) = tup {
40 41 | # [ cfg ( not ( stage0 ) ) ] {
41 42 | ( $ crate :: io :: _print ( format_args_nl ! ( $ ( $ arg ) * ) ) ) ; } # [
42 43 | cfg ( stage0 ) ] { print ! ( "{}/n" , format_args ! ( $ ( $ arg ) * ) ) } } else {
43 44 | ( $ crate :: io :: _print ( format_args_nl ! ( $ ( $ arg ) * ) ) ) ; }
44    |
45
46 error: you don't need to add `&` to all patterns
47   --> $DIR/matches.rs:40:5
48    |
49 40 | /     match tup {
50 41 | |         &(v, 1) => println!("{}", v),
51 42 | |         _ => println!("none"),
52 43 | |     }
53    | |_____^
54 help: instead of prefixing all patterns with `&`, you can dereference the expression
55    |
56 40 |     match *tup {
57 41 |         (v, 1) => println!("{}", v),
58    |
59
60 error: you don't need to add `&` to both the expression and the patterns
61   --> $DIR/matches.rs:46:5
62    |
63 46 | /     match &w {
64 47 | |         &Some(v) => println!("{:?}", v),
65 48 | |         &None => println!("none"),
66 49 | |     }
67    | |_____^
68 help: try
69    |
70 46 |     match w {
71 47 |         Some(v) => println!("{:?}", v),
72 48 |         None => println!("none"),
73    |
74
75 error: you don't need to add `&` to all patterns
76   --> $DIR/matches.rs:57:5
77    |
78 57 | /     if let &None = a {
79 58 | |         println!("none");
80 59 | |     }
81    | |_____^
82 help: instead of prefixing all patterns with `&`, you can dereference the expression
83    |
84 57 |     if let None = *a {
85    |            ^^^^   ^^
86
87 error: you don't need to add `&` to both the expression and the patterns
88   --> $DIR/matches.rs:62:5
89    |
90 62 | /     if let &None = &b {
91 63 | |         println!("none");
92 64 | |     }
93    | |_____^
94 help: try
95    |
96 62 |     if let None = b {
97    |            ^^^^   ^
98
99 error: some ranges overlap
100   --> $DIR/matches.rs:71:9
101    |
102 71 |         0 ... 10 => println!("0 ... 10"),
103    |         ^^^^^^^^
104    |
105    = note: `-D match-overlapping-arm` implied by `-D warnings`
106 note: overlaps with this
107   --> $DIR/matches.rs:72:9
108    |
109 72 |         0 ... 11 => println!("0 ... 11"),
110    |         ^^^^^^^^
111
112 error: some ranges overlap
113   --> $DIR/matches.rs:77:9
114    |
115 77 |         0 ... 5 => println!("0 ... 5"),
116    |         ^^^^^^^
117    |
118 note: overlaps with this
119   --> $DIR/matches.rs:79:9
120    |
121 79 |         FOO ... 11 => println!("0 ... 11"),
122    |         ^^^^^^^^^^
123
124 error: some ranges overlap
125   --> $DIR/matches.rs:85:9
126    |
127 85 |         0 ... 5 => println!("0 ... 5"),
128    |         ^^^^^^^
129    |
130 note: overlaps with this
131   --> $DIR/matches.rs:84:9
132    |
133 84 |         2 => println!("2"),
134    |         ^
135
136 error: some ranges overlap
137   --> $DIR/matches.rs:91:9
138    |
139 91 |         0 ... 2 => println!("0 ... 2"),
140    |         ^^^^^^^
141    |
142 note: overlaps with this
143   --> $DIR/matches.rs:90:9
144    |
145 90 |         2 => println!("2"),
146    |         ^
147
148 error: some ranges overlap
149    --> $DIR/matches.rs:114:9
150     |
151 114 |         0 .. 11 => println!("0 .. 11"),
152     |         ^^^^^^^
153     |
154 note: overlaps with this
155    --> $DIR/matches.rs:115:9
156     |
157 115 |         0 ... 11 => println!("0 ... 11"),
158     |         ^^^^^^^^
159
160 error: Err(_) will match all errors, maybe not a good idea
161    --> $DIR/matches.rs:132:9
162     |
163 132 |         Err(_) => panic!("err")
164     |         ^^^^^^
165     |
166     = note: `-D match-wild-err-arm` implied by `-D warnings`
167     = note: to remove this warning, match each error separately or use unreachable macro
168
169 error: this `match` has identical arm bodies
170    --> $DIR/matches.rs:131:18
171     |
172 131 |         Ok(_) => println!("ok"),
173     |                  ^^^^^^^^^^^^^^
174     |
175     = note: `-D match-same-arms` implied by `-D warnings`
176 note: same as this
177    --> $DIR/matches.rs:130:18
178     |
179 130 |         Ok(3) => println!("ok"),
180     |                  ^^^^^^^^^^^^^^
181 note: consider refactoring into `Ok(3) | Ok(_)`
182    --> $DIR/matches.rs:130:18
183     |
184 130 |         Ok(3) => println!("ok"),
185     |                  ^^^^^^^^^^^^^^
186     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
187
188 error: Err(_) will match all errors, maybe not a good idea
189    --> $DIR/matches.rs:138:9
190     |
191 138 |         Err(_) => {panic!()}
192     |         ^^^^^^
193     |
194     = note: to remove this warning, match each error separately or use unreachable macro
195
196 error: this `match` has identical arm bodies
197    --> $DIR/matches.rs:137:18
198     |
199 137 |         Ok(_) => println!("ok"),
200     |                  ^^^^^^^^^^^^^^
201     |
202 note: same as this
203    --> $DIR/matches.rs:136:18
204     |
205 136 |         Ok(3) => println!("ok"),
206     |                  ^^^^^^^^^^^^^^
207 note: consider refactoring into `Ok(3) | Ok(_)`
208    --> $DIR/matches.rs:136:18
209     |
210 136 |         Ok(3) => println!("ok"),
211     |                  ^^^^^^^^^^^^^^
212     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
213
214 error: Err(_) will match all errors, maybe not a good idea
215    --> $DIR/matches.rs:144:9
216     |
217 144 |         Err(_) => {panic!();}
218     |         ^^^^^^
219     |
220     = note: to remove this warning, match each error separately or use unreachable macro
221
222 error: this `match` has identical arm bodies
223    --> $DIR/matches.rs:143:18
224     |
225 143 |         Ok(_) => println!("ok"),
226     |                  ^^^^^^^^^^^^^^
227     |
228 note: same as this
229    --> $DIR/matches.rs:142:18
230     |
231 142 |         Ok(3) => println!("ok"),
232     |                  ^^^^^^^^^^^^^^
233 note: consider refactoring into `Ok(3) | Ok(_)`
234    --> $DIR/matches.rs:142:18
235     |
236 142 |         Ok(3) => println!("ok"),
237     |                  ^^^^^^^^^^^^^^
238     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
239
240 error: this `match` has identical arm bodies
241    --> $DIR/matches.rs:150:18
242     |
243 150 |         Ok(_) => println!("ok"),
244     |                  ^^^^^^^^^^^^^^
245     |
246 note: same as this
247    --> $DIR/matches.rs:149:18
248     |
249 149 |         Ok(3) => println!("ok"),
250     |                  ^^^^^^^^^^^^^^
251 note: consider refactoring into `Ok(3) | Ok(_)`
252    --> $DIR/matches.rs:149:18
253     |
254 149 |         Ok(3) => println!("ok"),
255     |                  ^^^^^^^^^^^^^^
256     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
257
258 error: this `match` has identical arm bodies
259    --> $DIR/matches.rs:157:18
260     |
261 157 |         Ok(_) => println!("ok"),
262     |                  ^^^^^^^^^^^^^^
263     |
264 note: same as this
265    --> $DIR/matches.rs:156:18
266     |
267 156 |         Ok(3) => println!("ok"),
268     |                  ^^^^^^^^^^^^^^
269 note: consider refactoring into `Ok(3) | Ok(_)`
270    --> $DIR/matches.rs:156:18
271     |
272 156 |         Ok(3) => println!("ok"),
273     |                  ^^^^^^^^^^^^^^
274     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
275
276 error: this `match` has identical arm bodies
277    --> $DIR/matches.rs:163:18
278     |
279 163 |         Ok(_) => println!("ok"),
280     |                  ^^^^^^^^^^^^^^
281     |
282 note: same as this
283    --> $DIR/matches.rs:162:18
284     |
285 162 |         Ok(3) => println!("ok"),
286     |                  ^^^^^^^^^^^^^^
287 note: consider refactoring into `Ok(3) | Ok(_)`
288    --> $DIR/matches.rs:162:18
289     |
290 162 |         Ok(3) => println!("ok"),
291     |                  ^^^^^^^^^^^^^^
292     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
293
294 error: this `match` has identical arm bodies
295    --> $DIR/matches.rs:169:18
296     |
297 169 |         Ok(_) => println!("ok"),
298     |                  ^^^^^^^^^^^^^^
299     |
300 note: same as this
301    --> $DIR/matches.rs:168:18
302     |
303 168 |         Ok(3) => println!("ok"),
304     |                  ^^^^^^^^^^^^^^
305 note: consider refactoring into `Ok(3) | Ok(_)`
306    --> $DIR/matches.rs:168:18
307     |
308 168 |         Ok(3) => println!("ok"),
309     |                  ^^^^^^^^^^^^^^
310     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
311
312 error: this `match` has identical arm bodies
313    --> $DIR/matches.rs:190:29
314     |
315 190 |         (Ok(_), Some(x)) => println!("ok {}", x),
316     |                             ^^^^^^^^^^^^^^^^^^^^
317     |
318 note: same as this
319    --> $DIR/matches.rs:189:29
320     |
321 189 |         (Ok(x), Some(_)) => println!("ok {}", x),
322     |                             ^^^^^^^^^^^^^^^^^^^^
323 note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))`
324    --> $DIR/matches.rs:189:29
325     |
326 189 |         (Ok(x), Some(_)) => println!("ok {}", x),
327     |                             ^^^^^^^^^^^^^^^^^^^^
328     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
329
330 error: this `match` has identical arm bodies
331    --> $DIR/matches.rs:205:18
332     |
333 205 |         Ok(_) => println!("ok"),
334     |                  ^^^^^^^^^^^^^^
335     |
336 note: same as this
337    --> $DIR/matches.rs:204:18
338     |
339 204 |         Ok(3) => println!("ok"),
340     |                  ^^^^^^^^^^^^^^
341 note: consider refactoring into `Ok(3) | Ok(_)`
342    --> $DIR/matches.rs:204:18
343     |
344 204 |         Ok(3) => println!("ok"),
345     |                  ^^^^^^^^^^^^^^
346     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
347
348 error: use as_ref() instead
349    --> $DIR/matches.rs:212:33
350     |
351 212 |       let borrowed: Option<&()> = match owned {
352     |  _________________________________^
353 213 | |         None => None,
354 214 | |         Some(ref v) => Some(v),
355 215 | |     };
356     | |_____^ help: try this: `owned.as_ref()`
357     |
358     = note: `-D match-as-ref` implied by `-D warnings`
359
360 error: use as_mut() instead
361    --> $DIR/matches.rs:218:39
362     |
363 218 |       let borrow_mut: Option<&mut ()> = match mut_owned {
364     |  _______________________________________^
365 219 | |         None => None,
366 220 | |         Some(ref mut v) => Some(v),
367 221 | |     };
368     | |_____^ help: try this: `mut_owned.as_mut()`
369
370 error: aborting due to 26 previous errors
371