-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.F-try_blocks`#![feature(try_blocks)]``#![feature(try_blocks)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
The following code fails to compile (rustc --edition=2018
):
#![feature(try_blocks)]
fn main() {
match try { 0 } {
None => (),
Some(_) => ()
};
}
The compiler error is:
error: expected expression, found reserved keyword `try`
--> test.rs:3:11
|
3 | match try { 0 } {
| ----- ^^^ expected expression
| |
| while parsing this match expression
Adding parentheses or braces, it will compile fine:
match ( try { 0 } ) { ... } //warning: unnecessary parentheses around `match` head expression
match { try { 0 } } { ... }
The same issue happens with other constructs such as:
if let Some(_) = try { 0 } { }
for _ in try { 0 } { } //should fail because of "cannot infer type", not "expected expression"
Metadata
Metadata
Assignees
Labels
A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.F-try_blocks`#![feature(try_blocks)]``#![feature(try_blocks)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.