Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_parse/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ impl<'a> Parser<'a> {
force_collect: ForceCollect,
force_full_expr: bool,
) -> PResult<'a, Stmt> {
self.current_closure.take();

let pre_attr_pos = self.collect_pos();
let attrs = self.parse_outer_attributes()?;
let lo = self.token.span;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Regression test for https://github.com/rust-lang/rust/issues/159989

fn main() {
for<> || -> () {};
//~^ ERROR `for<...>` binders for closures are experimental
for<'a> || -> () |_;
//~^ ERROR expected one of `,`, `:`, or `|`, found `;`
//~| ERROR expected one of `,`, `:`, or `|`, found `;`
//~| ERROR expected `{`, found `|`
//~| ERROR `for<...>` binders for closures are experimental
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
error: expected one of `,`, `:`, or `|`, found `;`
--> $DIR/missing-braces-before-close-brace.rs:6:24
|
LL | for<'a> || -> () |_;
| ^ expected one of `,`, `:`, or `|`

error: expected one of `,`, `:`, or `|`, found `;`
--> $DIR/missing-braces-before-close-brace.rs:6:24
|
LL | for<'a> || -> () |_;
| ^ expected one of `,`, `:`, or `|`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: expected `{`, found `|`
--> $DIR/missing-braces-before-close-brace.rs:6:22
|
LL | for<'a> || -> () |_;
| ^ expected `{`

error[E0658]: `for<...>` binders for closures are experimental
--> $DIR/missing-braces-before-close-brace.rs:4:5
|
LL | for<> || -> () {};
| ^^^^^
|
= 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
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= help: consider removing `for<...>`

error[E0658]: `for<...>` binders for closures are experimental
--> $DIR/missing-braces-before-close-brace.rs:6:5
|
LL | for<'a> || -> () |_;
| ^^^^^^^
|
= 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
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= help: consider removing `for<...>`

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0658`.
Loading