Skip to content

Commit a7f1649

Browse files
authored
Rollup merge of rust-lang#62607 - estebank:this-mem-is-out-of-control, r=petrochenkov
Correctly break out of recovery loop Fix rust-lang#61858.
2 parents d709e8d + 8c5f690 commit a7f1649

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/libsyntax/parse/parser.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4629,6 +4629,9 @@ impl<'a> Parser<'a> {
46294629
fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P<Block>> {
46304630
let mut stmts = vec![];
46314631
while !self.eat(&token::CloseDelim(token::Brace)) {
4632+
if self.token == token::Eof {
4633+
break;
4634+
}
46324635
let stmt = match self.parse_full_stmt(false) {
46334636
Err(mut err) => {
46344637
err.emit();
@@ -4643,8 +4646,6 @@ impl<'a> Parser<'a> {
46434646
};
46444647
if let Some(stmt) = stmt {
46454648
stmts.push(stmt);
4646-
} else if self.token == token::Eof {
4647-
break;
46484649
} else {
46494650
// Found only `;` or `}`.
46504651
continue;

src/test/ui/issues/issue-61858.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
(if foobar) //~ ERROR expected `{`, found `)`
3+
}

src/test/ui/issues/issue-61858.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: expected `{`, found `)`
2+
--> $DIR/issue-61858.rs:2:15
3+
|
4+
LL | (if foobar)
5+
| -- ^ expected `{`
6+
| |
7+
| this `if` statement has a condition, but no block
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)