about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2011-07-18 08:41:35 -0700
committerBrian Anderson <banderson@mozilla.com>2011-08-09 11:29:36 -0700
commita37e00ed1f7f06438630186ccd5c5fd2d0f8b251 (patch)
tree2b39dcc173af0618a3ff0e66d6416670b010d2e9 /src/comp
parentbf7b516bdbcb531a964063271c8cd4128125a6bc (diff)
downloadrust-a37e00ed1f7f06438630186ccd5c5fd2d0f8b251.tar.gz
rust-a37e00ed1f7f06438630186ccd5c5fd2d0f8b251.zip
Change the ivec type syntax to [T].
This preserves the old syntax for now.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/syntax/parse/parser.rs5
-rw-r--r--src/comp/syntax/print/pprust.rs17
2 files changed, 8 insertions, 14 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 133b3c41bc7..7f4d5b175d3 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -554,6 +554,11 @@ fn parse_ty(p: &parser) -> @ast::ty {
         t = ast::ty_vec(parse_mt(p));
         hi = p.get_hi_pos();
         expect(p, token::RBRACKET);
+    } else if (p.peek() == token::LBRACKET) {
+        expect(p, token::LBRACKET);
+        t = ast::ty_ivec(parse_mt(p));
+        hi = p.get_hi_pos();
+        expect(p, token::RBRACKET);
     } else if (eat_word(p, "fn")) {
         let flo = p.get_last_lo_pos();
         t = parse_ty_fn(ast::proto_fn, p, flo);
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 79fe8a9f8a4..1b34cd48304 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -287,24 +287,13 @@ fn print_type(s: &ps, ty: &ast::ty) {
       ast::ty_box(mt) { word(s.s, "@"); print_mt(s, mt); }
       ast::ty_vec(mt) { word(s.s, "vec["); print_mt(s, mt); word(s.s, "]"); }
       ast::ty_ivec(mt) {
-        let parens =
-            alt mt.ty.node {
-              ast::ty_box(_) | ast::ty_vec(_) | ast::ty_ptr(_) |
-              ast::ty_port(_) | ast::ty_chan(_) {
-                true
-              }
-              ast::ty_path(pt, _) { ivec::len(pt.node.types) > 0u }
-              _ { false }
-            };
-        if parens { popen(s); }
-        print_type(s, *mt.ty);
-        if parens { pclose(s); }
         word(s.s, "[");
         alt mt.mut {
-          ast::mut. { word(s.s, "mutable"); }
-          ast::maybe_mut. { word(s.s, "mutable?"); }
+          ast::mut. { word_space(s, "mutable"); }
+          ast::maybe_mut. { word_space(s, "mutable?"); }
           ast::imm. {}
         }
+        print_type(s, *mt.ty);
         word(s.s, "]");
       }
       ast::ty_ptr(mt) { word(s.s, "*"); print_mt(s, mt); }