diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-21 00:04:19 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-21 09:27:35 -0800 |
| commit | bc1d818b836644b67e2027cc358aa8d86f85e287 (patch) | |
| tree | 11b330e75932bfa569665e03314fc2c8bcbc1c5a /src/libsyntax/parse | |
| parent | 7e62684bb4cf10cef5f5335f5baaf838f3a541c0 (diff) | |
| parent | 2e86929a4a5a36f3993e577b4582ba70d84bbb40 (diff) | |
| download | rust-bc1d818b836644b67e2027cc358aa8d86f85e287.tar.gz rust-bc1d818b836644b67e2027cc358aa8d86f85e287.zip | |
rollup merge of #20057: nick29581/array-syntax
This does NOT break any existing programs because the `[_, ..n]` syntax is also supported. Part of #19999 r? @nikomatsakis
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 52aa609aeaf..19af118b190 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1545,7 +1545,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), @@ -1713,6 +1713,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 } @@ -2259,6 +2262,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(); |
