Correctly break out of recovery loop

This commit is contained in:
Esteban Küber
2019-07-11 20:02:54 -07:00
parent 4bb6b4a5ed
commit cc481a46cb

View File

@@ -4629,6 +4629,9 @@ impl<'a> Parser<'a> {
fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P<Block>> { fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P<Block>> {
let mut stmts = vec![]; let mut stmts = vec![];
while !self.eat(&token::CloseDelim(token::Brace)) { while !self.eat(&token::CloseDelim(token::Brace)) {
if self.token == token::Eof {
break;
}
let stmt = match self.parse_full_stmt(false) { let stmt = match self.parse_full_stmt(false) {
Err(mut err) => { Err(mut err) => {
err.emit(); err.emit();
@@ -4643,8 +4646,6 @@ impl<'a> Parser<'a> {
}; };
if let Some(stmt) = stmt { if let Some(stmt) = stmt {
stmts.push(stmt); stmts.push(stmt);
} else if self.token == token::Eof {
break;
} else { } else {
// Found only `;` or `}`. // Found only `;` or `}`.
continue; continue;