diff options
| author | Camelid <camelidcamel@gmail.com> | 2020-12-20 14:43:07 -0800 |
|---|---|---|
| committer | Camelid <camelidcamel@gmail.com> | 2021-01-12 19:25:51 -0800 |
| commit | 9959d6deedbf39d58fac06949596073d9c0dbb23 (patch) | |
| tree | bbb82c5d94aed4e35eacf9572400c75ea7016ad7 /src/test/ui/pattern | |
| parent | fe82cc38a0b3e39b9425090e2107c0ba15760491 (diff) | |
| download | rust-9959d6deedbf39d58fac06949596073d9c0dbb23.tar.gz rust-9959d6deedbf39d58fac06949596073d9c0dbb23.zip | |
Only suggest `..` if more than one field is missing
Diffstat (limited to 'src/test/ui/pattern')
| -rw-r--r-- | src/test/ui/pattern/issue-74539.stderr | 14 | ||||
| -rw-r--r-- | src/test/ui/pattern/pat-tuple-underfield.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/pattern/pat-tuple-underfield.stderr | 68 |
3 files changed, 26 insertions, 60 deletions
diff --git a/src/test/ui/pattern/issue-74539.stderr b/src/test/ui/pattern/issue-74539.stderr index 78249ed057f..49011d83e50 100644 --- a/src/test/ui/pattern/issue-74539.stderr +++ b/src/test/ui/pattern/issue-74539.stderr @@ -25,16 +25,10 @@ LL | A(u8, u8), | --------- tuple variant defined here ... LL | E::A(x @ ..) => { - | ^^^^^^^^^^^^ expected 2 fields, found 1 - | -help: use `_` to explicitly ignore each field - | -LL | E::A(x @ .., _) => { - | ^^^ -help: use `..` to ignore the rest of the fields - | -LL | E::A(x @ .., ..) => { - | ^^^^ + | ^^^^^^^^^^^- + | | | + | | help: use `_` to explicitly ignore each field + | expected 2 fields, found 1 error: aborting due to 3 previous errors diff --git a/src/test/ui/pattern/pat-tuple-underfield.rs b/src/test/ui/pattern/pat-tuple-underfield.rs index f306377e6e5..f86d6178014 100644 --- a/src/test/ui/pattern/pat-tuple-underfield.rs +++ b/src/test/ui/pattern/pat-tuple-underfield.rs @@ -8,13 +8,11 @@ fn main() { S(x) => {} //~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields //~| HELP use `_` to explicitly ignore each field - //~| HELP use `..` to ignore the rest of the fields } 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 - //~| HELP use `..` to ignore all fields } match S(0, 1.0) { S() => {} @@ -27,13 +25,11 @@ fn main() { E::S(x) => {} //~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields //~| HELP use `_` to explicitly ignore each field - //~| HELP use `..` to ignore the rest of the fields } 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 - //~| HELP use `..` to ignore all fields } match E::S(0, 1.0) { E::S() => {} diff --git a/src/test/ui/pattern/pat-tuple-underfield.stderr b/src/test/ui/pattern/pat-tuple-underfield.stderr index d1aaeaeafa4..6e7afd8e57b 100644 --- a/src/test/ui/pattern/pat-tuple-underfield.stderr +++ b/src/test/ui/pattern/pat-tuple-underfield.stderr @@ -1,5 +1,5 @@ error[E0532]: expected unit struct, unit variant or constant, found tuple variant `E::S` - --> $DIR/pat-tuple-underfield.rs:45:9 + --> $DIR/pat-tuple-underfield.rs:41:9 | LL | S(i32, f32), | ----------- `E::S` defined here @@ -14,37 +14,25 @@ LL | struct S(i32, f32); | ------------------- tuple struct defined here ... LL | S(x) => {} - | ^^^^ expected 2 fields, found 1 - | -help: use `_` to explicitly ignore each field - | -LL | S(x, _) => {} - | ^^^ -help: use `..` to ignore the rest of the fields - | -LL | S(x, ..) => {} - | ^^^^ + | ^^^- + | | | + | | help: use `_` to explicitly ignore each field + | expected 2 fields, found 1 error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields - --> $DIR/pat-tuple-underfield.rs:14:9 + --> $DIR/pat-tuple-underfield.rs:13:9 | LL | struct S(i32, f32); | ------------------- tuple struct defined here ... LL | S(_) => {} - | ^^^^ expected 2 fields, found 1 - | -help: use `_` to explicitly ignore each field - | -LL | S(_, _) => {} - | ^^^ -help: use `..` to ignore all fields - | -LL | S(..) => {} - | ^^ + | ^^^- + | | | + | | help: use `_` to explicitly ignore each field + | expected 2 fields, found 1 error[E0023]: this pattern has 0 fields, but the corresponding tuple struct has 2 fields - --> $DIR/pat-tuple-underfield.rs:20:9 + --> $DIR/pat-tuple-underfield.rs:18:9 | LL | struct S(i32, f32); | ------------------- tuple struct defined here @@ -62,43 +50,31 @@ LL | S(..) => {} | ^^ error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields - --> $DIR/pat-tuple-underfield.rs:27:9 + --> $DIR/pat-tuple-underfield.rs:25:9 | LL | S(i32, f32), | ----------- tuple variant defined here ... LL | E::S(x) => {} - | ^^^^^^^ expected 2 fields, found 1 - | -help: use `_` to explicitly ignore each field - | -LL | E::S(x, _) => {} - | ^^^ -help: use `..` to ignore the rest of the fields - | -LL | E::S(x, ..) => {} - | ^^^^ + | ^^^^^^- + | | | + | | help: use `_` to explicitly ignore each field + | expected 2 fields, found 1 error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields - --> $DIR/pat-tuple-underfield.rs:33:9 + --> $DIR/pat-tuple-underfield.rs:30:9 | LL | S(i32, f32), | ----------- tuple variant defined here ... LL | E::S(_) => {} - | ^^^^^^^ expected 2 fields, found 1 - | -help: use `_` to explicitly ignore each field - | -LL | E::S(_, _) => {} - | ^^^ -help: use `..` to ignore all fields - | -LL | E::S(..) => {} - | ^^ + | ^^^^^^- + | | | + | | help: use `_` to explicitly ignore each field + | expected 2 fields, found 1 error[E0023]: this pattern has 0 fields, but the corresponding tuple variant has 2 fields - --> $DIR/pat-tuple-underfield.rs:39:9 + --> $DIR/pat-tuple-underfield.rs:35:9 | LL | S(i32, f32), | ----------- tuple variant defined here |
