summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorCorey Richardson <corey@octayn.net>2014-12-05 10:06:50 -0800
committerCorey Richardson <corey@octayn.net>2014-12-05 10:06:50 -0800
commit26f2867c2e5439156f40f18c5a828a5a94c4352a (patch)
treed17972e0c7eac56590fa02d71292497afd926e00 /src/libsyntax/parse
parent2af097da0dc198b7289eae61b9a97185fd55ae0c (diff)
parentf5715f7867ab7e13fd3304d85861b1dcb1375a89 (diff)
downloadrust-26f2867c2e5439156f40f18c5a828a5a94c4352a.tar.gz
rust-26f2867c2e5439156f40f18c5a828a5a94c4352a.zip
rollup merge of #19413: P1start/more-trailing-commas
The only other place I know of that doesn’t allow trailing commas is closure types (#19414), and those are a bit tricky to fix (I suspect it might be impossible without infinite lookahead) so I didn’t implement that in this patch. There are other issues surrounding closure type parsing anyway, in particular #19410.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/attr.rs2
-rw-r--r--src/libsyntax/parse/common.rs7
-rw-r--r--src/libsyntax/parse/parser.rs5
3 files changed, 7 insertions, 7 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index db7bc6c323f..41fee1556ab 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -212,7 +212,7 @@ impl<'a> ParserAttr for Parser<'a> {
     fn parse_meta_seq(&mut self) -> Vec<P<ast::MetaItem>> {
         self.parse_seq(&token::OpenDelim(token::Paren),
                        &token::CloseDelim(token::Paren),
-                       seq_sep_trailing_disallowed(token::Comma),
+                       seq_sep_trailing_allowed(token::Comma),
                        |p| p.parse_meta_item()).node
     }
 
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs
index 3842170d677..a96bf1ce10b 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -19,18 +19,13 @@ pub struct SeqSep {
     pub trailing_sep_allowed: bool
 }
 
-pub fn seq_sep_trailing_disallowed(t: token::Token) -> SeqSep {
-    SeqSep {
-        sep: Some(t),
-        trailing_sep_allowed: false,
-    }
-}
 pub fn seq_sep_trailing_allowed(t: token::Token) -> SeqSep {
     SeqSep {
         sep: Some(t),
         trailing_sep_allowed: true,
     }
 }
+
 pub fn seq_sep_none() -> SeqSep {
     SeqSep {
         sep: None,
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 920bcc3a951..cb953a4dcf4 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3111,6 +3111,11 @@ impl<'a> Parser<'a> {
                 first = false;
             } else {
                 self.expect(&token::Comma);
+
+                if self.token == token::CloseDelim(token::Bracket)
+                        && (before_slice || after.len() != 0) {
+                    break
+                }
             }
 
             if before_slice {