about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-26 13:32:18 +0100
committerGitHub <noreply@github.com>2020-03-26 13:32:18 +0100
commit37e186087c28891d04dd67c8657c9affc8cdc59a (patch)
treefc45cbc37cbbb8cf794ddf3c5e607220feb2e140 /src/test
parentf9d1378dd497a1e48ec63adc7a704937f9a5a108 (diff)
parent73c82030e893ab259081bf38b4259e05156c32d0 (diff)
downloadrust-37e186087c28891d04dd67c8657c9affc8cdc59a.tar.gz
rust-37e186087c28891d04dd67c8657c9affc8cdc59a.zip
Rollup merge of #70417 - rakshith-ravi:master, r=Centril
parser: recover on `...` as a pattern, suggesting `..`

Fixes #70388

My first PR to rust. So please let me know if I'm doing something wrong.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/parser/issue-70388-recover-dotdotdot-rest-pat.rs7
-rw-r--r--src/test/ui/parser/issue-70388-recover-dotdotdot-rest-pat.stderr29
2 files changed, 36 insertions, 0 deletions
diff --git a/src/test/ui/parser/issue-70388-recover-dotdotdot-rest-pat.rs b/src/test/ui/parser/issue-70388-recover-dotdotdot-rest-pat.rs
new file mode 100644
index 00000000000..ca8abd78c47
--- /dev/null
+++ b/src/test/ui/parser/issue-70388-recover-dotdotdot-rest-pat.rs
@@ -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
+}
diff --git a/src/test/ui/parser/issue-70388-recover-dotdotdot-rest-pat.stderr b/src/test/ui/parser/issue-70388-recover-dotdotdot-rest-pat.stderr
new file mode 100644
index 00000000000..4961e8fc049
--- /dev/null
+++ b/src/test/ui/parser/issue-70388-recover-dotdotdot-rest-pat.stderr
@@ -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`.