-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
140 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
enum E { | ||
A(u8, u8), | ||
} | ||
|
||
fn main() { | ||
let e = E::A(2, 3); | ||
match e { | ||
E::A(x @ ..) => { | ||
//~^ ERROR: `x @` is not allowed in a tuple struct | ||
//~| ERROR: `..` patterns are not allowed here | ||
//~| ERROR: this pattern has 1 field, but the corresponding tuple variant has 2 fields | ||
x | ||
} | ||
}; | ||
} |
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,32 @@ | ||
error: `x @` is not allowed in a tuple struct | ||
--> $DIR/issue-74539.rs:8:14 | ||
| | ||
LL | E::A(x @ ..) => { | ||
| ^^^^^^ this is only allowed in slice patterns | ||
| | ||
= help: remove this and bind each tuple field independently | ||
help: if you don't need to use the contents of x, discard the tuple's remaining fields | ||
| | ||
LL | E::A(..) => { | ||
| ^^ | ||
|
||
error: `..` patterns are not allowed here | ||
--> $DIR/issue-74539.rs:8:18 | ||
| | ||
LL | E::A(x @ ..) => { | ||
| ^^ | ||
| | ||
= note: only allowed in tuple, tuple struct, and slice patterns | ||
|
||
error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields | ||
--> $DIR/issue-74539.rs:8:9 | ||
| | ||
LL | A(u8, u8), | ||
| --------- tuple variant defined here | ||
... | ||
LL | E::A(x @ ..) => { | ||
| ^^^^^^^^^^^^ expected 2 fields, found 1 | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0023`. |
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,7 @@ | ||
fn main() { | ||
let (foo @ ..,) = (0, 0); | ||
//~^ ERROR: `foo @` is not allowed in a tuple | ||
//~| ERROR: `..` patterns are not allowed here | ||
//~| ERROR: mismatched types | ||
dbg!(foo); | ||
} |
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,34 @@ | ||
error: `foo @` is not allowed in a tuple | ||
--> $DIR/issue-74702.rs:2:10 | ||
| | ||
LL | let (foo @ ..,) = (0, 0); | ||
| ^^^^^^^^ this is only allowed in slice patterns | ||
| | ||
= help: remove this and bind each tuple field independently | ||
help: if you don't need to use the contents of foo, discard the tuple's remaining fields | ||
| | ||
LL | let (..,) = (0, 0); | ||
| ^^ | ||
|
||
error: `..` patterns are not allowed here | ||
--> $DIR/issue-74702.rs:2:16 | ||
| | ||
LL | let (foo @ ..,) = (0, 0); | ||
| ^^ | ||
| | ||
= note: only allowed in tuple, tuple struct, and slice patterns | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-74702.rs:2:9 | ||
| | ||
LL | let (foo @ ..,) = (0, 0); | ||
| ^^^^^^^^^^^ ------ this expression has type `({integer}, {integer})` | ||
| | | ||
| expected a tuple with 2 elements, found one with 1 element | ||
| | ||
= note: expected tuple `({integer}, {integer})` | ||
found tuple `(_,)` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,7 @@ | ||
// check-pass | ||
|
||
fn main() { | ||
if let Some([b'@', filename @ ..]) = Some(b"@abc123") { | ||
println!("filename {:?}", filename); | ||
} | ||
} |