]> git.lizzy.rs Git - rust.git/commitdiff
Change the ivec type syntax to [T].
authorErick Tryzelaar <erick.tryzelaar@gmail.com>
Mon, 18 Jul 2011 15:41:35 +0000 (08:41 -0700)
committerBrian Anderson <banderson@mozilla.com>
Tue, 9 Aug 2011 18:29:36 +0000 (11:29 -0700)
This preserves the old syntax for now.

18 files changed:
src/comp/syntax/parse/parser.rs
src/comp/syntax/print/pprust.rs
src/test/bench/task-perf-word-count.rs
src/test/compiletest/compiletest.rs
src/test/compiletest/header.rs
src/test/compiletest/procsrv.rs
src/test/pretty/ivec-type.pp [new file with mode: 0644]
src/test/pretty/ivec-type.rs [new file with mode: 0644]
src/test/run-pass/alloca-from-derived-tydesc.rs
src/test/run-pass/autobind.rs
src/test/run-pass/infer-fn-tail-expr.rs
src/test/run-pass/interior-vec.rs
src/test/run-pass/issue-687.rs
src/test/run-pass/ivec-add.rs
src/test/run-pass/ivec-pass-by-value.rs
src/test/run-pass/task-comm-16.rs
src/test/stdtest/ivec.rs
src/test/stdtest/sort_ivec.rs

index 133b3c41bc7abf12e1e6fa08947d9d2e53f0e48a..7f4d5b175d33ffa691e4cd8c666efecb3d5b2133 100644 (file)
@@ -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);
index 79fe8a9f8a43199b01e9f02530e1ac6fea4b37a1..1b34cd4830440e3e415c845dda187746fb802d40 100644 (file)
@@ -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); }
index 0a6b94c7f2ed22736f9673725ec28091f2eb1c27..8b71014f8509a5aa55347c6e5304a6dd4cedce9c 100644 (file)
@@ -73,13 +73,13 @@ mod map_reduce {
     type reducer = fn(str, getter) ;
 
     tag ctrl_proto {
-        find_reducer(u8[], chan[chan[reduce_proto]]);
+        find_reducer([u8], chan[chan[reduce_proto]]);
         mapper_done;
     }
 
     tag reduce_proto { emit_val(int); done; ref; release; }
 
-    fn start_mappers(ctrl: chan[ctrl_proto], inputs: vec[str]) -> task[] {
+    fn start_mappers(ctrl: chan[ctrl_proto], inputs: vec[str]) -> [task] {
         let tasks = ~[];
         // log_err "starting mappers";
         for i: str  in inputs {
index 2b4776148dff330f9c53d2ece68abc41ef6623d0..40898556b9c8b3487972f1ebd53277d04a4e92cd 100644 (file)
@@ -25,7 +25,7 @@ fn main(args: vec[str]) {
     run_tests(config);
 }
 
-fn parse_config(args: &str[]) -> config {
+fn parse_config(args: &[str]) -> config {
     let opts =
         ~[getopts::reqopt("compile-lib-path"),
           getopts::reqopt("run-lib-path"), getopts::reqopt("rustc-path"),
@@ -117,7 +117,7 @@ fn test_opts(config: &config) -> test::test_opts {
 }
 
 type tests_and_conv_fn =
-    {tests: test::test_desc[], to_task: fn(&fn() ) -> task };
+    {tests: [test::test_desc], to_task: fn(&fn() ) -> task };
 
 fn make_tests(cx: &cx) -> tests_and_conv_fn {
     log #fmt("making tests from %s", cx.config.src_base);
index 41619ad9de5c6153db7b1188b4bd1a5619c866f8..46fc29e18fcd2b5bbbed6a075521670631feb81c 100644 (file)
@@ -11,7 +11,7 @@
 
 type test_props = {
     // Lines that should be expected, in order, on standard out
-    error_patterns: str[],
+    error_patterns: [str],
     // Extra flags to pass to the compiler
     compile_flags: option::t[str],
     // If present, the name of a file that this test should match when
index 582e093e6f13ee0c9d21e0ea3457e6822edb60ed..99f746e6b742c8298c50823e96b949b3c2895448 100644 (file)
@@ -27,7 +27,7 @@
 type handle = {task: option::t[task], chan: reqchan};
 
 tag request {
-    exec(str, str, str[], chan[response]);
+    exec(str, str, [str], chan[response]);
     stop;
 }
 
@@ -189,7 +189,7 @@ fn clone_str(s: &str) -> str {
     new
 }
 
-fn clone_ivecstr(v: &str[]) -> str[] {
+fn clone_ivecstr(v: &[str]) -> [str] {
     let r = ~[];
     for t: str in ivec::slice(v, 0u, ivec::len(v)) {
         r += ~[clone_str(t)];
diff --git a/src/test/pretty/ivec-type.pp b/src/test/pretty/ivec-type.pp
new file mode 100644 (file)
index 0000000..92862ac
--- /dev/null
@@ -0,0 +1,9 @@
+// pp-exact:ivec-type.pp
+
+fn f1(x: [int]) { }
+
+fn g1() { f1(~[1, 2, 3]); }
+
+fn f2(x: [int]) { }
+
+fn g2() { f2(~[1, 2, 3]); }
diff --git a/src/test/pretty/ivec-type.rs b/src/test/pretty/ivec-type.rs
new file mode 100644 (file)
index 0000000..a825519
--- /dev/null
@@ -0,0 +1,9 @@
+// pp-exact:ivec-type.pp
+
+fn f1(x: int[]) { }
+
+fn g1() { f1(~[1, 2, 3]); }
+
+fn f2(x: [int]) { }
+
+fn g2() { f2(~[1, 2, 3]); }
index bc4aa52ce97d1f5f0a3343f5402478b531a61d1a..24f3b755f2f3b9583cea83a3ab8a59c1c9265b42 100644 (file)
@@ -2,6 +2,6 @@
 
 type r[T] = {mutable v: (option[T])[]};
 
-fn f[T]() -> T[] { ret ~[]; }
+fn f[T]() -> [T] { ret ~[]; }
 
-fn main() { let r: r[int] = {mutable v: ~[]}; r.v = f(); }
\ No newline at end of file
+fn main() { let r: r[int] = {mutable v: ~[]}; r.v = f(); }
index 935fbef1acf2ffce1de9afbbea2a79b28dbf9762..668806802130099f159339ea8ddcb4940093cea5 100644 (file)
@@ -1,9 +1,9 @@
-fn f[T](x: &T[]) -> T { ret x.(0); }
+fn f[T](x: &[T]) -> T { ret x.(0); }
 
-fn g(act: fn(&int[]) -> int ) -> int { ret act(~[1, 2, 3]); }
+fn g(act: fn(&[int]) -> int ) -> int { ret act(~[1, 2, 3]); }
 
 fn main() {
     assert (g(f) == 1);
-    let f1: fn(&str[]) -> str  = f;
+    let f1: fn(&[str]) -> str  = f;
     assert (f1(~["x", "y", "z"]) == "x");
-}
\ No newline at end of file
+}
index 311bfdb5301a32d5081cd2ddc94fe0ca1b2f0488..9134f3a78de52a087f31e75eba74043ef115d0af 100644 (file)
@@ -1,5 +1,5 @@
 // issue #680
 
-fn f() -> int[] { ~[] }
+fn f() -> [int] { ~[] }
 
-fn main() { }
\ No newline at end of file
+fn main() { }
index 50cb704b88166e3353e814c9eb3eabd40466d86d..dec51540cff42fa262a73ecced44c35385acdeac 100644 (file)
@@ -3,11 +3,11 @@
 import rusti::ivec_len;
 
 native "rust-intrinsic" mod rusti {
-    fn ivec_len[T](v: &T[]) -> uint;
+    fn ivec_len[T](v: &[T]) -> uint;
 }
 
 fn main() {
-    let v: int[] = ~[];
+    let v: [int] = ~[];
     assert (ivec_len(v) == 0u); // zero-length
     let x = ~[1, 2];
     assert (ivec_len(x) == 2u); // on stack
index 200dd6273035f49234be3bdf79f2aa2625ab6134..2e682e2154ea1057c66e9c5145cbcb5eece515f0 100644 (file)
@@ -1,20 +1,20 @@
 use std;
 import std::ivec;
 
-tag msg { closed; received(u8[]); }
+tag msg { closed; received([u8]); }
 
-fn producer(c: chan[u8[]]) {
+fn producer(c: chan[[u8]]) {
     c <| ~[1u8, 2u8, 3u8, 4u8];
-    let empty: u8[] = ~[];
+    let empty: [u8] = ~[];
     c <| empty;
 }
 
-fn packager(cb: chan[chan[u8[]]], msg: chan[msg]) {
-    let p: port[u8[]] = port();
+fn packager(cb: chan[chan[[u8]]], msg: chan[msg]) {
+    let p: port[[u8]] = port();
     cb <| chan(p);
     while true {
         log "waiting for bytes";
-        let data: u8[];
+        let data: [u8];
         p |> data;
         log "got bytes";
         if ivec::len[u8](data) == 0u {
@@ -33,10 +33,10 @@ fn packager(cb: chan[chan[u8[]]], msg: chan[msg]) {
 
 fn main() {
     let p: port[msg] = port();
-    let recv_reader: port[chan[u8[]]] = port();
+    let recv_reader: port[chan[[u8]]] = port();
     let pack = spawn packager(chan(recv_reader), chan(p));
 
-    let source_chan: chan[u8[]];
+    let source_chan: chan[[u8]];
     recv_reader |> source_chan;
     let prod: task = spawn producer(source_chan);
 
@@ -52,4 +52,4 @@ fn main() {
           }
         }
     }
-}
\ No newline at end of file
+}
index 18ea2f23273c2823ffca426106cc7de46033e831..edf42f2fa910605e97e00fee4412ef9f55e04f23 100644 (file)
@@ -1,6 +1,6 @@
-fn double[T](a: &T) -> T[] { ret ~[a] + ~[a]; }
+fn double[T](a: &T) -> [T] { ret ~[a] + ~[a]; }
 
-fn double_int(a: int) -> int[] { ret ~[a] + ~[a]; }
+fn double_int(a: int) -> [int] { ret ~[a] + ~[a]; }
 
 fn main() {
     let d = double(1);
index cd0eadc45954867204c9e7dfb7604264555f7db6..213e13846581f34125419cb752f2d7d98130ab63 100644 (file)
@@ -1,3 +1,3 @@
-fn f(a: int[]) { }
+fn f(a: [int]) { }
 fn main() { f(~[1, 2, 3, 4, 5]); }
 
index c75b26e4b614f93927665502a5f4f82206ca209e..bd6f70752001bc1d1c108d6c0dde7b77c5bdebb3 100644 (file)
@@ -22,9 +22,9 @@ fn test_rec() {
 fn test_vec() {
     let po = comm::mk_port();
     let ch = po.mk_chan();
-    let v0: int[] = ~[0, 1, 2];
+    let v0: [int] = ~[0, 1, 2];
     ch.send(v0);
-    let v1: int[];
+    let v1: [int];
     v1 = po.recv();
     assert (v1.(0) == 0);
     assert (v1.(1) == 1);
@@ -84,4 +84,4 @@ fn main() {
     test_str();
     test_tag();
     test_chan();
-}
\ No newline at end of file
+}
index ab486b46e0b0853057b4ef725b19d4377ce2833a..766587e6c76cb972393914243c56eec478100298 100644 (file)
@@ -19,7 +19,7 @@ fn square_if_odd(n: &uint) -> option::t[uint] {
 
 #[test]
 fn test_reserve_and_on_heap() {
-    let v: int[] = ~[1, 2];
+    let v: [int] = ~[1, 2];
     assert (!ivec::on_heap(v));
     ivec::reserve(v, 8u);
     assert (ivec::on_heap(v));
index 14654a89ad9bfbd1915b2576a4b2c7fd7aef139b..3e52de4ad2e74eda68f372b11048999c39c4b41f 100644 (file)
@@ -1,7 +1,7 @@
 
 use std;
 
-fn check_sort(v1: &int[], v2: &int[]) {
+fn check_sort(v1: &[int], v2: &[int]) {
     let len = std::ivec::len[int](v1);
     fn lteq(a: &int, b: &int) -> bool { ret a <= b; }
     let f = lteq;
@@ -18,11 +18,11 @@ fn test() {
         check_sort(v1, v2);
     }
     { let v1 = ~[1, 1, 1]; let v2 = ~[1, 1, 1]; check_sort(v1, v2); }
-    { let v1: int[] = ~[]; let v2: int[] = ~[]; check_sort(v1, v2); }
+    { let v1: [int] = ~[]; let v2: [int] = ~[]; check_sort(v1, v2); }
     { let v1 = ~[9]; let v2 = ~[9]; check_sort(v1, v2); }
     {
         let v1 = ~[9, 3, 3, 3, 9];
         let v2 = ~[3, 3, 3, 9, 9];
         check_sort(v1, v2);
     }
-}
\ No newline at end of file
+}