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
This commit is contained in:
commit
bc1d818b83
122 changed files with 260 additions and 266 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue