1
Fork 0
This commit is contained in:
Kampfkarren 2019-04-10 19:22:43 -07:00
parent 4af7cf37d4
commit 1156ce6f54
3 changed files with 4 additions and 3 deletions

View file

@ -3620,8 +3620,9 @@ impl<'a> Parser<'a> {
attrs.extend(iattrs); attrs.extend(iattrs);
if self.eat_keyword(keywords::Catch) { if self.eat_keyword(keywords::Catch) {
let mut error = self.struct_span_err(self.prev_span, let mut error = self.struct_span_err(self.prev_span,
"`try {} catch` is not a valid syntax"); "keyword `catch` cannot follow a `try` block");
error.help("try using `match` on the result of the `try` block instead"); error.help("try using `match` on the result of the `try` block instead");
error.emit();
Err(error) Err(error)
} else { } else {
Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs)) Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs))

View file

@ -6,5 +6,5 @@ fn main() {
let res: Option<bool> = try { let res: Option<bool> = try {
true true
} catch { }; } catch { };
//~^ ERROR `try {} catch` is not a valid syntax //~^ ERROR keyword `catch` cannot follow a `try` block
} }

View file

@ -1,4 +1,4 @@
error: `try {} catch` is not a valid syntax error: keyword `catch` cannot follow a `try` block
--> $DIR/try-block-catch.rs:8:7 --> $DIR/try-block-catch.rs:8:7
| |
LL | } catch { }; LL | } catch { };