about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2014-12-20 15:20:51 +1300
committerNick Cameron <ncameron@mozilla.com>2014-12-20 15:23:29 +1300
commit2e86929a4a5a36f3993e577b4582ba70d84bbb40 (patch)
tree7b3e8049edae74dde7a870a7173afed6f9fc744e /src/libsyntax/parse/parser.rs
parentcbe9fb45bc705a89f23b434c686544d490923596 (diff)
downloadrust-2e86929a4a5a36f3993e577b4582ba70d84bbb40.tar.gz
rust-2e86929a4a5a36f3993e577b4582ba70d84bbb40.zip
Allow use of `[_ ; n]` syntax for fixed length and repeating arrays.
This does NOT break any existing programs because the `[_, ..n]` syntax is also supported.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 3ad224b93ce..620dfd643d2 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1548,7 +1548,7 @@ impl<'a> Parser<'a> {
             self.expect(&token::OpenDelim(token::Bracket));
             let t = self.parse_ty_sum();
 
-            // Parse the `, ..e` in `[ int, ..e ]`
+            // Parse the `; e` in `[ int; e ]`
             // where `e` is a const expression
             let t = match self.maybe_parse_fixed_vstore() {
                 None => TyVec(t),
@@ -1716,6 +1716,9 @@ impl<'a> Parser<'a> {
             self.bump();
             self.bump();
             Some(self.parse_expr())
+        } else if self.check(&token::Semi) {
+            self.bump();
+            Some(self.parse_expr())
         } else {
             None
         }
@@ -2262,6 +2265,12 @@ impl<'a> Parser<'a> {
                         let count = self.parse_expr();
                         self.expect(&token::CloseDelim(token::Bracket));
                         ex = ExprRepeat(first_expr, count);
+                    } else if self.check(&token::Semi) {
+                        // Repeating vector syntax: [ 0; 512 ]
+                        self.bump();
+                        let count = self.parse_expr();
+                        self.expect(&token::CloseDelim(token::Bracket));
+                        ex = ExprRepeat(first_expr, count);
                     } else if self.check(&token::Comma) {
                         // Vector with two or more elements.
                         self.bump();