about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libsyntax/parse/parser.rs3
-rw-r--r--src/test/ui/try-block/try-block-catch.rs2
-rw-r--r--src/test/ui/try-block/try-block-catch.stderr2
3 files changed, 4 insertions, 3 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 4d2a9f2c13c..d95a5843eb5 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3620,8 +3620,9 @@ impl<'a> Parser<'a> {
         attrs.extend(iattrs);
         if self.eat_keyword(keywords::Catch) {
             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.emit();
             Err(error)
         } else {
             Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs))
diff --git a/src/test/ui/try-block/try-block-catch.rs b/src/test/ui/try-block/try-block-catch.rs
index a7dc41fc423..d165015611d 100644
--- a/src/test/ui/try-block/try-block-catch.rs
+++ b/src/test/ui/try-block/try-block-catch.rs
@@ -6,5 +6,5 @@ fn main() {
     let res: Option<bool> = try {
         true
     } catch { };
-    //~^ ERROR `try {} catch` is not a valid syntax
+    //~^ ERROR keyword `catch` cannot follow a `try` block
 }
diff --git a/src/test/ui/try-block/try-block-catch.stderr b/src/test/ui/try-block/try-block-catch.stderr
index b54cc3ccbbb..39cf943f4d8 100644
--- a/src/test/ui/try-block/try-block-catch.stderr
+++ b/src/test/ui/try-block/try-block-catch.stderr
@@ -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
    |
 LL |     } catch { };