rust/tests/ui/pattern/slice-pattern-refutable.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
693 B
Rust
Raw Normal View History

2023-07-10 17:11:21 -05:00
// Test that we do not infer the expected types of patterns to an array
// if we're in a refutable pattern.
2023-06-30 06:42:37 -05:00
#![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() {}