Skip to content

Commit 1156ce6

Browse files
committed
Feedback
1 parent 4af7cf3 commit 1156ce6

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3620,8 +3620,9 @@ impl<'a> Parser<'a> {
36203620
attrs.extend(iattrs);
36213621
if self.eat_keyword(keywords::Catch) {
36223622
let mut error = self.struct_span_err(self.prev_span,
3623-
"`try {} catch` is not a valid syntax");
3623+
"keyword `catch` cannot follow a `try` block");
36243624
error.help("try using `match` on the result of the `try` block instead");
3625+
error.emit();
36253626
Err(error)
36263627
} else {
36273628
Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs))

src/test/ui/try-block/try-block-catch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ fn main() {
66
let res: Option<bool> = try {
77
true
88
} catch { };
9-
//~^ ERROR `try {} catch` is not a valid syntax
9+
//~^ ERROR keyword `catch` cannot follow a `try` block
1010
}

src/test/ui/try-block/try-block-catch.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: `try {} catch` is not a valid syntax
1+
error: keyword `catch` cannot follow a `try` block
22
--> $DIR/try-block-catch.rs:8:7
33
|
44
LL | } catch { };

0 commit comments

Comments
 (0)