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