Skip to content

Commit b0bea10

Browse files
committed
libsyntax: Accept the new [T, ..N] style for vec.
1 parent 049e1f9 commit b0bea10

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,9 @@ pub impl Parser {
642642
self.obsolete(*self.last_span, ObsoleteMutVector);
643643
}
644644

645-
// Parse the `* e` in `[ int * e ]`
645+
// Parse the `, ..e` in `[ int, ..e ]`
646646
// where `e` is a const expression
647-
let t = match self.maybe_parse_fixed_vstore_with_star() {
647+
let t = match self.maybe_parse_fixed_vstore() {
648648
None => ty_vec(mt),
649649
Some(suffix) => ty_fixed_length_vec(mt, suffix)
650650
};
@@ -815,8 +815,14 @@ pub impl Parser {
815815
})
816816
}
817817

818-
fn maybe_parse_fixed_vstore_with_star(&self) -> Option<@ast::expr> {
818+
fn maybe_parse_fixed_vstore(&self) -> Option<@ast::expr> {
819819
if self.eat(&token::BINOP(token::STAR)) {
820+
// XXX: Obsolete; remove after snapshot.
821+
Some(self.parse_expr())
822+
} else if *self.token == token::COMMA &&
823+
self.look_ahead(1) == token::DOTDOT {
824+
self.bump();
825+
self.bump();
820826
Some(self.parse_expr())
821827
} else {
822828
None

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) {
424424
ast::m_imm => ()
425425
}
426426
print_type(s, mt.ty);
427-
word(s.s, ~" * ");
427+
word(s.s, ~", ..");
428428
print_expr(s, v);
429429
word(s.s, ~"]");
430430
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use core::io::println;
2+
3+
static FOO: [int, ..3] = [1, 2, 3];
4+
5+
fn main() {
6+
println(fmt!("%d %d %d", FOO[0], FOO[1], FOO[2]));
7+
}
8+
9+
10+

0 commit comments

Comments
 (0)