]> git.lizzy.rs Git - rust.git/commitdiff
Correctly break out of recovery loop
authorEsteban Küber <esteban@kuber.com.ar>
Fri, 12 Jul 2019 03:02:54 +0000 (20:02 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Fri, 12 Jul 2019 03:02:54 +0000 (20:02 -0700)
src/libsyntax/parse/parser.rs

index 83dbff6b2d5746dda8bb5757a0032904a352fd8d..ce32491117b8baa7885c2b75eb27e8245ce96124 100644 (file)
@@ -4629,6 +4629,9 @@ fn parse_inner_attrs_and_block(&mut self) -> PResult<'a, (Vec<Attribute>, P<Bloc
     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 @@ fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P<Blo
             };
             if let Some(stmt) = stmt {
                 stmts.push(stmt);
-            } else if self.token == token::Eof {
-                break;
             } else {
                 // Found only `;` or `}`.
                 continue;