parse: move condition into guard

This commit is contained in:
Mazdak Farrokhzad 2020-02-25 00:59:39 +01:00
parent 32295aee6e
commit 1eb0844f5d

View file

@ -366,9 +366,10 @@ impl<'a> Parser<'a> {
let mut eat_semi = true;
match stmt.kind {
StmtKind::Expr(ref expr) if self.token != token::Eof => {
// expression without semicolon
if classify::expr_requires_semi_to_be_stmt(expr) {
// Expression without semicolon.
StmtKind::Expr(ref expr)
if self.token != token::Eof && classify::expr_requires_semi_to_be_stmt(expr) =>
{
// Just check for errors and recover; do not eat semicolon yet.
if let Err(mut e) =
self.expect_one_of(&[], &[token::Semi, token::CloseDelim(token::Brace)])
@ -397,7 +398,6 @@ impl<'a> Parser<'a> {
stmt.kind = StmtKind::Expr(self.mk_expr_err(sp));
}
}
}
StmtKind::Local(..) => {
self.expect_semi()?;
eat_semi = false;