diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2016-03-18 15:49:12 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2016-03-23 09:26:32 +1300 |
| commit | 3ee841c3351326a7bea83b689f54d9fee27e6e85 (patch) | |
| tree | 2f9752dcc0ba739b1cc5beba767ae1e895786aa5 /src/libsyntax/parse | |
| parent | e3f2dfdececa8053e652eb0fb286db9aef0f82e6 (diff) | |
| download | rust-3ee841c3351326a7bea83b689f54d9fee27e6e85.tar.gz rust-3ee841c3351326a7bea83b689f54d9fee27e6e85.zip | |
Don't loop forever on error recovery with EOF
closes #31804
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6839f11cd70..66912abb6f5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3824,7 +3824,9 @@ impl<'a> Parser<'a> { fn recover_stmt_(&mut self, break_on_semi: SemiColonMode) { let mut brace_depth = 0; let mut bracket_depth = 0; + debug!("recover_stmt_ enter loop"); loop { + debug!("recover_stmt_ loop {:?}", self.token); match self.token { token::OpenDelim(token::DelimToken::Brace) => { brace_depth += 1; @@ -3836,6 +3838,7 @@ impl<'a> Parser<'a> { } token::CloseDelim(token::DelimToken::Brace) => { if brace_depth == 0 { + debug!("recover_stmt_ return - close delim {:?}", self.token); return; } brace_depth -= 1; @@ -3848,12 +3851,16 @@ impl<'a> Parser<'a> { } self.bump(); } - token::Eof => return, + token::Eof => { + debug!("recover_stmt_ return - Eof"); + return; + } token::Semi => { self.bump(); if break_on_semi == SemiColonMode::Break && brace_depth == 0 && bracket_depth == 0 { + debug!("recover_stmt_ return - Semi"); return; } } @@ -4042,6 +4049,8 @@ impl<'a> Parser<'a> { while !self.eat(&token::CloseDelim(token::Brace)) { let Spanned {node, span} = if let Some(s) = self.parse_stmt_() { s + } else if self.token == token::Eof { + break; } else { // Found only `;` or `}`. continue; |
