about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-21 08:32:55 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-03-21 09:54:03 +0100
commit4d30b92e3e57cf606a25c807a9e4ab2b7a4d1064 (patch)
treee606e765361b6774803a3d77835eab422ebbf4b6 /src/test/ui/parser
parent2835ca65845c5fac8da2a2612a06b12ad2f4c77c (diff)
downloadrust-4d30b92e3e57cf606a25c807a9e4ab2b7a4d1064.tar.gz
rust-4d30b92e3e57cf606a25c807a9e4ab2b7a4d1064.zip
recover on `for<'a> |...| body` closures.
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/recover-quantified-closure.rs10
-rw-r--r--src/test/ui/parser/recover-quantified-closure.stderr16
2 files changed, 26 insertions, 0 deletions
diff --git a/src/test/ui/parser/recover-quantified-closure.rs b/src/test/ui/parser/recover-quantified-closure.rs
new file mode 100644
index 00000000000..381324738f6
--- /dev/null
+++ b/src/test/ui/parser/recover-quantified-closure.rs
@@ -0,0 +1,10 @@
+fn main() {
+    for<'a> |x: &'a u8| *x + 1;
+    //~^ ERROR cannot introduce explicit parameters for a closure
+}
+
+enum Foo { Bar }
+fn foo(x: impl Iterator<Item = Foo>) {
+    for <Foo>::Bar in x {}
+    //~^ ERROR expected one of `move`, `static`, `|`
+}
diff --git a/src/test/ui/parser/recover-quantified-closure.stderr b/src/test/ui/parser/recover-quantified-closure.stderr
new file mode 100644
index 00000000000..0f011326516
--- /dev/null
+++ b/src/test/ui/parser/recover-quantified-closure.stderr
@@ -0,0 +1,16 @@
+error: cannot introduce explicit parameters for a closure
+  --> $DIR/recover-quantified-closure.rs:2:5
+   |
+LL |     for<'a> |x: &'a u8| *x + 1;
+   |     ^^^^^^^ ------------------ the parameters are attached to this closure
+   |     |
+   |     help: remove the parameters
+
+error: expected one of `move`, `static`, `|`, or `||`, found `::`
+  --> $DIR/recover-quantified-closure.rs:8:14
+   |
+LL |     for <Foo>::Bar in x {}
+   |              ^^ expected one of `move`, `static`, `|`, or `||`
+
+error: aborting due to 2 previous errors
+