2013-04-17 21:36:59 -05:00
|
|
|
// Test that certain pattern-match type errors are non-fatal
|
|
|
|
|
|
|
|
enum A {
|
2015-01-08 04:54:35 -06:00
|
|
|
B(isize, isize),
|
|
|
|
C(isize, isize, isize),
|
2013-04-17 21:36:59 -05:00
|
|
|
D
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
2015-01-08 04:54:35 -06:00
|
|
|
a: isize
|
2013-04-17 21:36:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn f(_c: char) {}
|
|
|
|
|
|
|
|
fn main() {
|
2014-11-06 02:05:53 -06:00
|
|
|
match A::B(1, 2) {
|
|
|
|
A::B(_, _, _) => (), //~ ERROR this pattern has 3 fields, but
|
2019-10-14 19:20:50 -05:00
|
|
|
A::D(_) => (), //~ ERROR expected tuple struct or tuple variant, found unit variant `A::D`
|
2013-04-17 21:36:59 -05:00
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
match 'c' {
|
2014-10-20 20:40:15 -05:00
|
|
|
S { .. } => (),
|
2015-01-12 00:01:44 -06:00
|
|
|
//~^ ERROR mismatched types
|
2023-01-02 20:00:33 -06:00
|
|
|
//~| expected `char`, found `S`
|
2013-08-12 18:44:07 -05:00
|
|
|
|
2013-04-17 21:36:59 -05:00
|
|
|
_ => ()
|
|
|
|
}
|
2015-01-12 00:01:44 -06:00
|
|
|
f(true);
|
|
|
|
//~^ ERROR mismatched types
|
2019-11-15 11:37:01 -06:00
|
|
|
//~| expected `char`, found `bool`
|
2016-04-16 21:37:15 -05:00
|
|
|
|
|
|
|
match () {
|
2020-08-27 07:27:14 -05:00
|
|
|
E::V => {} //~ ERROR failed to resolve: use of undeclared type `E`
|
2016-04-16 21:37:15 -05:00
|
|
|
}
|
2013-08-12 18:44:07 -05:00
|
|
|
}
|