diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2016-03-26 21:37:53 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2016-04-07 15:37:07 +0200 |
| commit | c0167543dbaaf0dff10b8296955b7aa824e6973d (patch) | |
| tree | c2d8c3aa1b6846dd8fe20f7f1fbfdd22e86d1f26 /src/libsyntax/parse/parser.rs | |
| parent | 39d612b7ac08aa97fb78b1791c47584cbdc46d8f (diff) | |
| download | rust-c0167543dbaaf0dff10b8296955b7aa824e6973d.tar.gz rust-c0167543dbaaf0dff10b8296955b7aa824e6973d.zip | |
syntax: Stop the bump loop for trait items at } and EOF.
backport of 221d0fbad0b201ef9264d3c9a30cd8c143ed51b2 to beta with hand-resolution of conflicts and reverting to `try!` syntax.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ccb9654aed4..64dd60feb4e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -941,7 +941,9 @@ impl<'a> Parser<'a> { { try!(self.expect(bra)); let result = self.parse_seq_to_before_end(ket, sep, f); - self.bump(); + if self.token == *ket { + self.bump(); + } Ok(result) } @@ -1276,15 +1278,21 @@ impl<'a> Parser<'a> { Ok(cua) => cua, Err(e) => { loop { - p.bump(); - if p.token == token::Semi { - p.bump(); - break; - } + match p.token { + token::Eof => break, + + token::CloseDelim(token::Brace) | + token::Semi => { + p.bump(); + break; + } + + token::OpenDelim(token::Brace) => { + try!(p.parse_token_tree()); + break; + } - if p.token == token::OpenDelim(token::DelimToken::Brace) { - try!(p.parse_token_tree()); - break; + _ => p.bump() } } |
