about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-07-14 14:14:21 +0530
committerGitHub <noreply@github.com>2022-07-14 14:14:21 +0530
commite5a86d7358520477b816e118200fc7dc664b3f6e (patch)
treecc3b8f12948902b3551659742f499570ccce5951 /src/test/ui/parser
parent103b8602b7e3cfc8301ab9e0981563bde3789ea7 (diff)
parent9aa142b5f1cf85e9941f7f9a35caa604500dab8b (diff)
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/recover-quantified-closure.rs4
-rw-r--r--src/test/ui/parser/recover-quantified-closure.stderr37
2 files changed, 32 insertions, 9 deletions
diff --git a/src/test/ui/parser/recover-quantified-closure.rs b/src/test/ui/parser/recover-quantified-closure.rs
index 381324738f6..10af39b7007 100644
--- a/src/test/ui/parser/recover-quantified-closure.rs
+++ b/src/test/ui/parser/recover-quantified-closure.rs
@@ -1,10 +1,12 @@
 fn main() {
     for<'a> |x: &'a u8| *x + 1;
-    //~^ ERROR cannot introduce explicit parameters for a closure
+    //~^ ERROR `for<...>` binders for closures are experimental
+    //~^^ ERROR implicit types in closure signatures are forbidden when `for<...>` is present
 }
 
 enum Foo { Bar }
 fn foo(x: impl Iterator<Item = Foo>) {
     for <Foo>::Bar in x {}
     //~^ ERROR expected one of `move`, `static`, `|`
+    //~^^ ERROR `for<...>` binders for closures are experimental
 }
diff --git a/src/test/ui/parser/recover-quantified-closure.stderr b/src/test/ui/parser/recover-quantified-closure.stderr
index 0f011326516..39eec80f658 100644
--- a/src/test/ui/parser/recover-quantified-closure.stderr
+++ b/src/test/ui/parser/recover-quantified-closure.stderr
@@ -1,16 +1,37 @@
-error: cannot introduce explicit parameters for a closure
+error: expected one of `move`, `static`, `|`, or `||`, found `::`
+  --> $DIR/recover-quantified-closure.rs:9:14
+   |
+LL |     for <Foo>::Bar in x {}
+   |              ^^ expected one of `move`, `static`, `|`, or `||`
+
+error[E0658]: `for<...>` binders for closures are experimental
   --> $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
+   |     ^^^^^^^
+   |
+   = note: see issue #97362 <https://github.com/rust-lang/rust/issues/97362> for more information
+   = help: add `#![feature(closure_lifetime_binder)]` to the crate attributes to enable
+   = help: consider removing `for<...>`
 
-error: expected one of `move`, `static`, `|`, or `||`, found `::`
-  --> $DIR/recover-quantified-closure.rs:8:14
+error[E0658]: `for<...>` binders for closures are experimental
+  --> $DIR/recover-quantified-closure.rs:9:5
    |
 LL |     for <Foo>::Bar in x {}
-   |              ^^ expected one of `move`, `static`, `|`, or `||`
+   |     ^^^^^^^^^
+   |
+   = note: see issue #97362 <https://github.com/rust-lang/rust/issues/97362> for more information
+   = help: add `#![feature(closure_lifetime_binder)]` to the crate attributes to enable
+   = help: consider removing `for<...>`
+
+error: implicit types in closure signatures are forbidden when `for<...>` is present
+  --> $DIR/recover-quantified-closure.rs:2:25
+   |
+LL |     for<'a> |x: &'a u8| *x + 1;
+   |     -------             ^
+   |     |
+   |     `for<...>` is here
 
-error: aborting due to 2 previous errors
+error: aborting due to 4 previous errors
 
+For more information about this error, try `rustc --explain E0658`.