forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#88123 - camelid:tup-pat-precise-spans, r=es…
…tebank Make spans for tuple patterns in E0023 more precise As suggested in rust-lang#86307. Closes rust-lang#86307. r? ``@estebank``
- Loading branch information
Showing
19 changed files
with
1,165 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/test/ui/pattern/auxiliary/declarations-for-tuple-field-count-errors.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
pub struct Z0; | ||
pub struct Z1(); | ||
|
||
pub struct S(pub u8, pub u8, pub u8); | ||
pub struct M( | ||
pub u8, | ||
pub u8, | ||
pub u8, | ||
); | ||
|
||
pub enum E1 { Z0, Z1(), S(u8, u8, u8) } | ||
|
||
pub enum E2 { | ||
S(u8, u8, u8), | ||
M( | ||
u8, | ||
u8, | ||
u8, | ||
), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// aux-build:declarations-for-tuple-field-count-errors.rs | ||
|
||
extern crate declarations_for_tuple_field_count_errors; | ||
|
||
use declarations_for_tuple_field_count_errors::*; | ||
|
||
fn main() { | ||
match Z0 { | ||
Z0() => {} //~ ERROR expected tuple struct or tuple variant, found unit struct `Z0` | ||
Z0(x) => {} //~ ERROR expected tuple struct or tuple variant, found unit struct `Z0` | ||
} | ||
match Z1() { | ||
Z1 => {} //~ ERROR match bindings cannot shadow tuple structs | ||
Z1(x) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple struct has 0 fields | ||
} | ||
|
||
match S(1, 2, 3) { | ||
S() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple struct has 3 fields | ||
S(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple struct has 3 fields | ||
S(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple struct has 3 fields | ||
S(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields | ||
} | ||
match M(1, 2, 3) { | ||
M() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple struct has 3 fields | ||
M(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple struct has 3 fields | ||
M(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple struct has 3 fields | ||
M(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields | ||
} | ||
|
||
match E1::Z0 { | ||
E1::Z0() => {} //~ ERROR expected tuple struct or tuple variant, found unit variant `E1::Z0` | ||
E1::Z0(x) => {} //~ ERROR expected tuple struct or tuple variant, found unit variant `E1::Z0` | ||
} | ||
match E1::Z1() { | ||
E1::Z1 => {} //~ ERROR expected unit struct, unit variant or constant, found tuple variant `E1::Z1` | ||
E1::Z1(x) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple variant has 0 fields | ||
} | ||
match E1::S(1, 2, 3) { | ||
E1::S() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple variant has 3 fields | ||
E1::S(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple variant has 3 fields | ||
E1::S(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields | ||
E1::S(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple variant has 3 fields | ||
} | ||
|
||
match E2::S(1, 2, 3) { | ||
E2::S() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple variant has 3 fields | ||
E2::S(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple variant has 3 fields | ||
E2::S(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields | ||
E2::S(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple variant has 3 fields | ||
} | ||
match E2::M(1, 2, 3) { | ||
E2::M() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple variant has 3 fields | ||
E2::M(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple variant has 3 fields | ||
E2::M(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields | ||
E2::M(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple variant has 3 fields | ||
} | ||
} |
Oops, something went wrong.