-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw error when encountering
...
instead of ..
while destructing…
… a pattern Added tests and stderr output
- Loading branch information
1 parent
a17dd36
commit 73c8203
Showing
3 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
struct Foo(i32); | ||
|
||
fn main() { | ||
let Foo(...) = Foo(0); //~ ERROR unexpected `...` | ||
let [_, ..., _] = [0, 1]; //~ ERROR unexpected `...` | ||
let _recovery_witness: () = 0; //~ ERROR mismatched types | ||
} |
29 changes: 29 additions & 0 deletions
29
src/test/ui/parser/issue-70388-recover-dotdotdot-rest-pat.stderr
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,29 @@ | ||
error: unexpected `...` | ||
--> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:4:13 | ||
| | ||
LL | let Foo(...) = Foo(0); | ||
| ^^^ | ||
| | | ||
| not a valid pattern | ||
| help: for a rest pattern, use `..` instead of `...` | ||
|
||
error: unexpected `...` | ||
--> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:5:13 | ||
| | ||
LL | let [_, ..., _] = [0, 1]; | ||
| ^^^ | ||
| | | ||
| not a valid pattern | ||
| help: for a rest pattern, use `..` instead of `...` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:6:33 | ||
| | ||
LL | let _recovery_witness: () = 0; | ||
| -- ^ expected `()`, found integer | ||
| | | ||
| expected due to this | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |