rust/tests/ui/suggestions/match-ergonomics.rs
2023-01-11 09:32:08 +00:00

42 lines
757 B
Rust

fn main() {
let x = vec![1i32];
match &x[..] {
[&v] => {}, //~ ERROR mismatched types
_ => {},
}
match x {
[&v] => {}, //~ ERROR expected an array or slice
_ => {},
}
match &x[..] {
[v] => {},
_ => {},
}
match &x[..] {
&[v] => {},
_ => {},
}
match x {
[v] => {}, //~ ERROR expected an array or slice
_ => {},
}
let y = 1i32;
match &y {
&v => {},
_ => {},
}
match y {
&v => {}, //~ ERROR mismatched types
_ => {},
}
match &y {
v => {},
_ => {},
}
match y {
v => {},
_ => {},
}
if let [&v] = &x[..] {} //~ ERROR mismatched types
}