Skip to content

Commit

Permalink
Rollup merge of rust-lang#62607 - estebank:this-mem-is-out-of-control…
Browse files Browse the repository at this point in the history
…, r=petrochenkov

Correctly break out of recovery loop

Fix rust-lang#61858.
  • Loading branch information
Centril authored Jul 12, 2019
2 parents d709e8d + 8c5f690 commit a7f1649
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4629,6 +4629,9 @@ impl<'a> Parser<'a> {
fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P<Block>> {
let mut stmts = vec![];
while !self.eat(&token::CloseDelim(token::Brace)) {
if self.token == token::Eof {
break;
}
let stmt = match self.parse_full_stmt(false) {
Err(mut err) => {
err.emit();
Expand All @@ -4643,8 +4646,6 @@ impl<'a> Parser<'a> {
};
if let Some(stmt) = stmt {
stmts.push(stmt);
} else if self.token == token::Eof {
break;
} else {
// Found only `;` or `}`.
continue;
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/issues/issue-61858.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
(if foobar) //~ ERROR expected `{`, found `)`
}
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-61858.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: expected `{`, found `)`
--> $DIR/issue-61858.rs:2:15
|
LL | (if foobar)
| -- ^ expected `{`
| |
| this `if` statement has a condition, but no block

error: aborting due to previous error

0 comments on commit a7f1649

Please sign in to comment.