about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2016-03-26 21:37:53 +0200
committerEduard Burtescu <edy.burt@gmail.com>2016-03-26 21:37:53 +0200
commit221d0fbad0b201ef9264d3c9a30cd8c143ed51b2 (patch)
treea1345f3c10550212746d2dce95e3ece2c948da25 /src/libsyntax/parse
parent6abab49029dacfaa616b726f49817213adc1065b (diff)
downloadrust-221d0fbad0b201ef9264d3c9a30cd8c143ed51b2.tar.gz
rust-221d0fbad0b201ef9264d3c9a30cd8c143ed51b2.zip
syntax: Stop the bump loop for trait items at } and EOF.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index c6a237d3827..b1af576c144 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -957,7 +957,9 @@ impl<'a> Parser<'a> {
     {
         self.expect(bra)?;
         let result = self.parse_seq_to_before_end(ket, sep, f);
-        self.bump();
+        if self.token == *ket {
+            self.bump();
+        }
         Ok(result)
     }
 
@@ -1292,15 +1294,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) => {
+                                    p.parse_token_tree()?;
+                                    break;
+                                }
 
-                            if p.token == token::OpenDelim(token::DelimToken::Brace) {
-                                p.parse_token_tree()?;
-                                break;
+                                _ => p.bump()
                             }
                         }