diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-04-12 20:36:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-12 20:36:11 +0200 |
| commit | 8f111951a19ab5e63ac347b2d029216c4e061cd4 (patch) | |
| tree | 40031015896ac21a2a7ba91f7787bb25534ee5ff /src/libsyntax/parse | |
| parent | 29f9dd236499d84ac4985886935f6bf6536e0772 (diff) | |
| parent | 1156ce6f54dde7555bb00828ba4ec6c2a170fc83 (diff) | |
| download | rust-8f111951a19ab5e63ac347b2d029216c4e061cd4.tar.gz rust-8f111951a19ab5e63ac347b2d029216c4e061cd4.zip | |
Rollup merge of #59847 - Kampfkarren:try-block-catch, r=estebank
Error when using `catch` after `try` Part of https://github.com/rust-lang/rust/issues/31436
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b51b7fd1ef5..30c816eb718 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4091,7 +4091,15 @@ impl<'a> Parser<'a> { { let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); - Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs)) + if self.eat_keyword(keywords::Catch) { + let mut error = self.struct_span_err(self.prev_span, + "keyword `catch` cannot follow a `try` block"); + error.help("try using `match` on the result of the `try` block instead"); + error.emit(); + Err(error) + } else { + Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs)) + } } // `match` token already eaten |
