]> git.lizzy.rs Git - rust.git/blob - tests/ui/typeck/issue-91328.rs
Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett
[rust.git] / tests / ui / typeck / issue-91328.rs
1 // Regression test for issue #91328.
2
3 // run-rustfix
4
5 #![allow(dead_code)]
6
7 fn foo(r: Result<Vec<i32>, i32>) -> i32 {
8     match r {
9     //~^ HELP: consider using `as_deref` here
10         Ok([a, b]) => a + b,
11         //~^ ERROR: expected an array or slice
12         //~| NOTE: pattern cannot match with input type
13         _ => 42,
14     }
15 }
16
17 fn bar(o: Option<Vec<i32>>) -> i32 {
18     match o {
19     //~^ HELP: consider using `as_deref` here
20         Some([a, b]) => a + b,
21         //~^ ERROR: expected an array or slice
22         //~| NOTE: pattern cannot match with input type
23         _ => 42,
24     }
25 }
26
27 fn baz(v: Vec<i32>) -> i32 {
28     match v {
29     //~^ HELP: consider slicing here
30         [a, b] => a + b,
31         //~^ ERROR: expected an array or slice
32         //~| NOTE: pattern cannot match with input type
33         _ => 42,
34     }
35 }
36
37 fn qux(a: &Option<Box<[i32; 2]>>) -> i32 {
38     match a {
39     //~^ HELP: consider using `as_deref` here
40         Some([a, b]) => a + b,
41         //~^ ERROR: expected an array or slice
42         //~| NOTE: pattern cannot match with input type
43         _ => 42,
44     }
45 }
46
47 fn main() {}