Skip to content

Commit 9a7cb93

Browse files
committed
Catch expression does not require semicolon to be a statement
1 parent 5e25dc9 commit 9a7cb93

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/libsyntax/parse/classify.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
3030
ast::ExprKind::While(..) |
3131
ast::ExprKind::WhileLet(..) |
3232
ast::ExprKind::Loop(..) |
33-
ast::ExprKind::ForLoop(..) => false,
33+
ast::ExprKind::ForLoop(..) |
34+
ast::ExprKind::Catch(..) => false,
3435
_ => true,
3536
}
3637
}

src/test/run-pass/catch-expr.rs

+6
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,10 @@ pub fn main() {
7171
Ok(&my_string)
7272
};
7373
assert_eq!(res, Ok("test"));
74+
75+
do catch {
76+
()
77+
}
78+
79+
();
7480
}

0 commit comments

Comments
 (0)