rust/src/test/compile-fail/non-exhaustive-match.rs

29 lines
655 B
Rust
Raw Normal View History

enum t { a, b, }
fn main() {
let x = a;
2012-08-06 14:34:08 -05:00
match x { b => { } } //~ ERROR non-exhaustive patterns
match true { //~ ERROR non-exhaustive patterns
2012-08-03 21:59:04 -05:00
true => {}
}
2012-08-20 14:23:37 -05:00
match @Some(10) { //~ ERROR non-exhaustive patterns
@None => {}
}
2012-08-06 14:34:08 -05:00
match (2, 3, 4) { //~ ERROR non-exhaustive patterns
2012-08-03 21:59:04 -05:00
(_, _, 4) => {}
}
2012-08-06 14:34:08 -05:00
match (a, a) { //~ ERROR non-exhaustive patterns
2012-08-03 21:59:04 -05:00
(a, b) => {}
(b, a) => {}
}
2012-08-06 14:34:08 -05:00
match a { //~ ERROR b not covered
2012-08-03 21:59:04 -05:00
a => {}
}
// This is exhaustive, though the algorithm got it wrong at one point
2012-08-06 14:34:08 -05:00
match (a, b) {
2012-08-03 21:59:04 -05:00
(a, _) => {}
(_, a) => {}
(b, b) => {}
}
}