Rollup merge of #64161 - estebank:point-variant, r=Centril

Point at variant on pattern field count mismatch
This commit is contained in:
Mazdak Farrokhzad 2019-09-06 09:36:42 +02:00 committed by GitHub
commit 6968e53a5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 9 deletions

View file

@ -1,18 +1,27 @@
error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
--> $DIR/E0023.rs:10:9
|
LL | Apple(String, String),
| --------------------- tuple variant defined here
...
LL | Fruit::Apple(a) => {},
| ^^^^^^^^^^^^^^^ expected 2 fields, found 1
error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
--> $DIR/E0023.rs:11:9
|
LL | Apple(String, String),
| --------------------- tuple variant defined here
...
LL | Fruit::Apple(a, b, c) => {},
| ^^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 3
error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 1 field
--> $DIR/E0023.rs:12:9
|
LL | Pear(u32),
| --------- tuple variant defined here
...
LL | Fruit::Pear(1, 2) => {},
| ^^^^^^^^^^^^^^^^^ expected 1 field, found 2

View file

@ -1,6 +1,9 @@
error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 3 fields
--> $DIR/match-pattern-field-mismatch.rs:10:11
|
LL | Rgb(usize, usize, usize),
| ------------------------ tuple variant defined here
...
LL | Color::Rgb(_, _) => { }
| ^^^^^^^^^^^^^^^^ expected 3 fields, found 2

View file

@ -19,12 +19,18 @@ LL | (1, 2, .., 3, 4) => {}
error[E0023]: this pattern has 4 fields, but the corresponding tuple struct has 3 fields
--> $DIR/pat-tuple-overfield.rs:10:9
|
LL | struct S(u8, u8, u8);
| --------------------- tuple struct defined here
...
LL | S(1, 2, 3, 4) => {}
| ^^^^^^^^^^^^^ expected 3 fields, found 4
error[E0023]: this pattern has 4 fields, but the corresponding tuple struct has 3 fields
--> $DIR/pat-tuple-overfield.rs:12:9
|
LL | struct S(u8, u8, u8);
| --------------------- tuple struct defined here
...
LL | S(1, 2, .., 3, 4) => {}
| ^^^^^^^^^^^^^^^^^ expected 3 fields, found 4

View file

@ -15,6 +15,9 @@ LL | A::D(_) => (),
error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
--> $DIR/pattern-error-continue.rs:17:9
|
LL | B(isize, isize),
| --------------- tuple variant defined here
...
LL | A::B(_, _, _) => (),
| ^^^^^^^^^^^^^ expected 2 fields, found 3