Skip to content

Commit dd15904

Browse files
committed
parse_bottom_expr: use else if
1 parent 52acaa6 commit dd15904

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/librustc_parse/parser/expr.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,21 +1093,20 @@ impl<'a> Parser<'a> {
10931093
let (await_hi, e_kind) = self.parse_incorrect_await_syntax(lo, self.prev_span)?;
10941094
hi = await_hi;
10951095
ex = e_kind;
1096+
} else if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
1097+
// Don't complain about bare semicolons after unclosed braces
1098+
// recovery in order to keep the error count down. Fixing the
1099+
// delimiters will possibly also fix the bare semicolon found in
1100+
// expression context. For example, silence the following error:
1101+
//
1102+
// error: expected expression, found `;`
1103+
// --> file.rs:2:13
1104+
// |
1105+
// 2 | foo(bar(;
1106+
// | ^ expected expression
1107+
self.bump();
1108+
return Ok(self.mk_expr(self.token.span, ExprKind::Err, ThinVec::new()));
10961109
} else {
1097-
if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
1098-
// Don't complain about bare semicolons after unclosed braces
1099-
// recovery in order to keep the error count down. Fixing the
1100-
// delimiters will possibly also fix the bare semicolon found in
1101-
// expression context. For example, silence the following error:
1102-
//
1103-
// error: expected expression, found `;`
1104-
// --> file.rs:2:13
1105-
// |
1106-
// 2 | foo(bar(;
1107-
// | ^ expected expression
1108-
self.bump();
1109-
return Ok(self.mk_expr(self.token.span, ExprKind::Err, ThinVec::new()));
1110-
}
11111110
parse_lit!()
11121111
}
11131112
}

0 commit comments

Comments
 (0)