libsyntax: Accept the new [T, ..N] style for vec.
This commit is contained in:
parent
049e1f9a1f
commit
b0bea10898
3 changed files with 20 additions and 4 deletions
|
|
@ -642,9 +642,9 @@ pub impl Parser {
|
|||
self.obsolete(*self.last_span, ObsoleteMutVector);
|
||||
}
|
||||
|
||||
// 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_with_star() {
|
||||
let t = match self.maybe_parse_fixed_vstore() {
|
||||
None => ty_vec(mt),
|
||||
Some(suffix) => ty_fixed_length_vec(mt, suffix)
|
||||
};
|
||||
|
|
@ -815,8 +815,14 @@ pub impl Parser {
|
|||
})
|
||||
}
|
||||
|
||||
fn maybe_parse_fixed_vstore_with_star(&self) -> Option<@ast::expr> {
|
||||
fn maybe_parse_fixed_vstore(&self) -> Option<@ast::expr> {
|
||||
if self.eat(&token::BINOP(token::STAR)) {
|
||||
// XXX: Obsolete; remove after snapshot.
|
||||
Some(self.parse_expr())
|
||||
} else if *self.token == token::COMMA &&
|
||||
self.look_ahead(1) == token::DOTDOT {
|
||||
self.bump();
|
||||
self.bump();
|
||||
Some(self.parse_expr())
|
||||
} else {
|
||||
None
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) {
|
|||
ast::m_imm => ()
|
||||
}
|
||||
print_type(s, mt.ty);
|
||||
word(s.s, ~" * ");
|
||||
word(s.s, ~", ..");
|
||||
print_expr(s, v);
|
||||
word(s.s, ~"]");
|
||||
}
|
||||
|
|
|
|||
10
src/test/run-pass/new-style-fixed-length-vec.rs
Normal file
10
src/test/run-pass/new-style-fixed-length-vec.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use core::io::println;
|
||||
|
||||
static FOO: [int, ..3] = [1, 2, 3];
|
||||
|
||||
fn main() {
|
||||
println(fmt!("%d %d %d", FOO[0], FOO[1], FOO[2]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue