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