From 049e1f9a1f60cfbc4136bd8496737e707ca05a42 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 19 Mar 2013 14:46:27 -0700 Subject: libsyntax: Accept `static` instead of `const` for globals --- src/libsyntax/print/pprust.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/print') diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 93583a1487a..36c9e36ed5d 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -452,7 +452,7 @@ pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) { end(s); // end the outer fn box } ast::foreign_item_const(t) => { - head(s, ~"const"); + head(s, ~"static"); print_ident(s, item.ident); word_space(s, ~":"); print_type(s, t); @@ -471,7 +471,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) { (s.ann.pre)(ann_node); match /*bad*/ copy item.node { ast::item_const(ty, expr) => { - head(s, visibility_qualified(item.vis, ~"const")); + head(s, visibility_qualified(item.vis, ~"static")); print_ident(s, item.ident); word_space(s, ~":"); print_type(s, ty); -- cgit 1.4.1-3-g733a5 From b0bea108983446aaa33ecabdd44954e03d5c65e0 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 19 Mar 2013 15:40:04 -0700 Subject: libsyntax: Accept the new `[T, ..N]` style for vec. --- src/libsyntax/parse/parser.rs | 12 +++++++++--- src/libsyntax/print/pprust.rs | 2 +- src/test/run-pass/new-style-fixed-length-vec.rs | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/test/run-pass/new-style-fixed-length-vec.rs (limited to 'src/libsyntax/print') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b224ccba114..40ef0bcc99e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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 diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 36c9e36ed5d..0937091cd13 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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, ~"]"); } diff --git a/src/test/run-pass/new-style-fixed-length-vec.rs b/src/test/run-pass/new-style-fixed-length-vec.rs new file mode 100644 index 00000000000..44261458a9a --- /dev/null +++ b/src/test/run-pass/new-style-fixed-length-vec.rs @@ -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])); +} + + + -- cgit 1.4.1-3-g733a5