2020-12-13 16:13:52 -06:00
|
|
|
struct S(i32, f32);
|
|
|
|
enum E {
|
|
|
|
S(i32, f32),
|
|
|
|
}
|
2021-01-12 18:47:04 -06:00
|
|
|
struct Point4(i32, i32, i32, i32);
|
2020-12-13 16:13:52 -06:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
match S(0, 1.0) {
|
|
|
|
S(x) => {}
|
|
|
|
//~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields
|
|
|
|
//~| HELP use `_` to explicitly ignore each field
|
|
|
|
}
|
|
|
|
match S(0, 1.0) {
|
|
|
|
S(_) => {}
|
|
|
|
//~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields
|
|
|
|
//~| HELP use `_` to explicitly ignore each field
|
2021-01-12 22:39:51 -06:00
|
|
|
//~| HELP use `..` to ignore all fields
|
2020-12-13 16:13:52 -06:00
|
|
|
}
|
|
|
|
match S(0, 1.0) {
|
|
|
|
S() => {}
|
|
|
|
//~^ ERROR this pattern has 0 fields, but the corresponding tuple struct has 2 fields
|
|
|
|
//~| HELP use `_` to explicitly ignore each field
|
2020-12-18 22:17:09 -06:00
|
|
|
//~| HELP use `..` to ignore all fields
|
2021-08-25 16:40:06 -05:00
|
|
|
|
|
|
|
// Test non-standard formatting
|
|
|
|
S () => {}
|
|
|
|
//~^ ERROR this pattern has 0 fields, but the corresponding tuple struct has 2 fields
|
|
|
|
//~| HELP use `_` to explicitly ignore each field
|
|
|
|
//~| HELP use `..` to ignore all fields
|
2020-12-13 16:13:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
match E::S(0, 1.0) {
|
|
|
|
E::S(x) => {}
|
|
|
|
//~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields
|
|
|
|
//~| HELP use `_` to explicitly ignore each field
|
|
|
|
}
|
|
|
|
match E::S(0, 1.0) {
|
|
|
|
E::S(_) => {}
|
|
|
|
//~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields
|
|
|
|
//~| HELP use `_` to explicitly ignore each field
|
2021-01-12 22:39:51 -06:00
|
|
|
//~| HELP use `..` to ignore all fields
|
2020-12-13 16:13:52 -06:00
|
|
|
}
|
|
|
|
match E::S(0, 1.0) {
|
|
|
|
E::S() => {}
|
|
|
|
//~^ ERROR this pattern has 0 fields, but the corresponding tuple variant has 2 fields
|
|
|
|
//~| HELP use `_` to explicitly ignore each field
|
2020-12-18 22:17:09 -06:00
|
|
|
//~| HELP use `..` to ignore all fields
|
2021-08-25 16:40:06 -05:00
|
|
|
|
|
|
|
// Test non-standard formatting
|
|
|
|
E::S () => {}
|
|
|
|
//~^ ERROR this pattern has 0 fields, but the corresponding tuple variant has 2 fields
|
|
|
|
//~| HELP use `_` to explicitly ignore each field
|
|
|
|
//~| HELP use `..` to ignore all fields
|
2020-12-13 16:13:52 -06:00
|
|
|
}
|
|
|
|
match E::S(0, 1.0) {
|
|
|
|
E::S => {}
|
|
|
|
//~^ ERROR expected unit struct, unit variant or constant, found tuple variant `E::S`
|
|
|
|
//~| HELP use the tuple variant pattern syntax instead
|
|
|
|
}
|
2021-01-12 18:47:04 -06:00
|
|
|
|
|
|
|
match Point4(0, 1, 2, 3) {
|
|
|
|
Point4( a , _ ) => {}
|
|
|
|
//~^ ERROR this pattern has 2 fields, but the corresponding tuple struct has 4 fields
|
|
|
|
//~| HELP use `_` to explicitly ignore each field
|
|
|
|
//~| HELP use `..` to ignore the rest of the fields
|
|
|
|
}
|
2020-12-13 16:13:52 -06:00
|
|
|
}
|