rust/tests/ui/pattern/slice-pattern-refutable.rs
2023-07-17 22:02:09 +00:00

35 lines
585 B
Rust

#![allow(unused_variables)]
struct Zeroes;
impl Into<[usize; 3]> for Zeroes {
fn into(self) -> [usize; 3] {
[0; 3]
}
}
fn let_else() {
let [a, b, c] = Zeroes.into() else {
//~^ ERROR type annotations needed
unreachable!();
};
}
fn if_let() {
if let [a, b, c] = Zeroes.into() {
//~^ ERROR type annotations needed
unreachable!();
}
}
fn if_let_else() {
if let [a, b, c] = Zeroes.into() {
//~^ ERROR type annotations needed
unreachable!();
} else {
unreachable!();
}
}
fn main() {}