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