diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-12 22:46:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-12 22:46:52 +0200 |
| commit | a7f1649fbbcdc2b9904a2614c36b44e917747898 (patch) | |
| tree | 8da66e7a281a969badf84cb6faf8e0a6bdfdc065 | |
| parent | d709e8d9d0c0629eb8727f4feaadb387bfde07c2 (diff) | |
| parent | 8c5f6907a1ddb1dc19a4163775f087a46ca77c40 (diff) | |
| download | rust-a7f1649fbbcdc2b9904a2614c36b44e917747898.tar.gz rust-a7f1649fbbcdc2b9904a2614c36b44e917747898.zip | |
Rollup merge of #62607 - estebank:this-mem-is-out-of-control, r=petrochenkov
Correctly break out of recovery loop Fix #61858.
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-61858.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-61858.stderr | 10 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 871fc0e7062..e0633f73ac4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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(); @@ -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; diff --git a/src/test/ui/issues/issue-61858.rs b/src/test/ui/issues/issue-61858.rs new file mode 100644 index 00000000000..6c3b56586c4 --- /dev/null +++ b/src/test/ui/issues/issue-61858.rs @@ -0,0 +1,3 @@ +fn main() { + (if foobar) //~ ERROR expected `{`, found `)` +} diff --git a/src/test/ui/issues/issue-61858.stderr b/src/test/ui/issues/issue-61858.stderr new file mode 100644 index 00000000000..ea2ec3d013f --- /dev/null +++ b/src/test/ui/issues/issue-61858.stderr @@ -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 + |
