Skip to content

Commit 4ea04c9

Browse files
committed
Change the ivec type syntax to [T].
This preserves the old syntax for now.
1 parent b2bfb1f commit 4ea04c9

18 files changed

+64
-52
lines changed

src/comp/syntax/parse/parser.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,11 @@ fn parse_ty(p: &parser) -> @ast::ty {
554554
t = ast::ty_vec(parse_mt(p));
555555
hi = p.get_hi_pos();
556556
expect(p, token::RBRACKET);
557+
} else if (p.peek() == token::LBRACKET) {
558+
expect(p, token::LBRACKET);
559+
t = ast::ty_ivec(parse_mt(p));
560+
hi = p.get_hi_pos();
561+
expect(p, token::RBRACKET);
557562
} else if (eat_word(p, "fn")) {
558563
let flo = p.get_last_lo_pos();
559564
t = parse_ty_fn(ast::proto_fn, p, flo);

src/comp/syntax/print/pprust.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,24 +287,13 @@ fn print_type(s: &ps, ty: &ast::ty) {
287287
ast::ty_box(mt) { word(s.s, "@"); print_mt(s, mt); }
288288
ast::ty_vec(mt) { word(s.s, "vec["); print_mt(s, mt); word(s.s, "]"); }
289289
ast::ty_ivec(mt) {
290-
let parens =
291-
alt mt.ty.node {
292-
ast::ty_box(_) | ast::ty_vec(_) | ast::ty_ptr(_) |
293-
ast::ty_port(_) | ast::ty_chan(_) {
294-
true
295-
}
296-
ast::ty_path(pt, _) { ivec::len(pt.node.types) > 0u }
297-
_ { false }
298-
};
299-
if parens { popen(s); }
300-
print_type(s, *mt.ty);
301-
if parens { pclose(s); }
302290
word(s.s, "[");
303291
alt mt.mut {
304-
ast::mut. { word(s.s, "mutable"); }
305-
ast::maybe_mut. { word(s.s, "mutable?"); }
292+
ast::mut. { word_space(s, "mutable"); }
293+
ast::maybe_mut. { word_space(s, "mutable?"); }
306294
ast::imm. {}
307295
}
296+
print_type(s, *mt.ty);
308297
word(s.s, "]");
309298
}
310299
ast::ty_ptr(mt) { word(s.s, "*"); print_mt(s, mt); }

src/test/bench/task-perf-word-count.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ mod map_reduce {
7373
type reducer = fn(str, getter) ;
7474

7575
tag ctrl_proto {
76-
find_reducer(u8[], chan[chan[reduce_proto]]);
76+
find_reducer([u8], chan[chan[reduce_proto]]);
7777
mapper_done;
7878
}
7979

8080
tag reduce_proto { emit_val(int); done; ref; release; }
8181

82-
fn start_mappers(ctrl: chan[ctrl_proto], inputs: vec[str]) -> task[] {
82+
fn start_mappers(ctrl: chan[ctrl_proto], inputs: vec[str]) -> [task] {
8383
let tasks = ~[];
8484
// log_err "starting mappers";
8585
for i: str in inputs {

src/test/compiletest/compiletest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main(args: vec[str]) {
2525
run_tests(config);
2626
}
2727

28-
fn parse_config(args: &str[]) -> config {
28+
fn parse_config(args: &[str]) -> config {
2929
let opts =
3030
~[getopts::reqopt("compile-lib-path"),
3131
getopts::reqopt("run-lib-path"), getopts::reqopt("rustc-path"),
@@ -117,7 +117,7 @@ fn test_opts(config: &config) -> test::test_opts {
117117
}
118118

119119
type tests_and_conv_fn =
120-
{tests: test::test_desc[], to_task: fn(&fn() ) -> task };
120+
{tests: [test::test_desc], to_task: fn(&fn() ) -> task };
121121

122122
fn make_tests(cx: &cx) -> tests_and_conv_fn {
123123
log #fmt("making tests from %s", cx.config.src_base);

src/test/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export is_test_ignored;
1111

1212
type test_props = {
1313
// Lines that should be expected, in order, on standard out
14-
error_patterns: str[],
14+
error_patterns: [str],
1515
// Extra flags to pass to the compiler
1616
compile_flags: option::t[str],
1717
// If present, the name of a file that this test should match when

src/test/compiletest/procsrv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type reqchan = chan[request];
2727
type handle = {task: option::t[task], chan: reqchan};
2828

2929
tag request {
30-
exec(str, str, str[], chan[response]);
30+
exec(str, str, [str], chan[response]);
3131
stop;
3232
}
3333

@@ -189,7 +189,7 @@ fn clone_str(s: &str) -> str {
189189
new
190190
}
191191

192-
fn clone_ivecstr(v: &str[]) -> str[] {
192+
fn clone_ivecstr(v: &[str]) -> [str] {
193193
let r = ~[];
194194
for t: str in ivec::slice(v, 0u, ivec::len(v)) {
195195
r += ~[clone_str(t)];

src/test/pretty/ivec-type.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// pp-exact:ivec-type.pp
2+
3+
fn f1(x: [int]) { }
4+
5+
fn g1() { f1(~[1, 2, 3]); }
6+
7+
fn f2(x: [int]) { }
8+
9+
fn g2() { f2(~[1, 2, 3]); }

src/test/pretty/ivec-type.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// pp-exact:ivec-type.pp
2+
3+
fn f1(x: int[]) { }
4+
5+
fn g1() { f1(~[1, 2, 3]); }
6+
7+
fn f2(x: [int]) { }
8+
9+
fn g2() { f2(~[1, 2, 3]); }

src/test/run-pass/alloca-from-derived-tydesc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ tag option[T] { some(T); none; }
22

33
type r[T] = {mutable v: (option[T])[]};
44

5-
fn f[T]() -> T[] { ret ~[]; }
5+
fn f[T]() -> [T] { ret ~[]; }
66

7-
fn main() { let r: r[int] = {mutable v: ~[]}; r.v = f(); }
7+
fn main() { let r: r[int] = {mutable v: ~[]}; r.v = f(); }

src/test/run-pass/autobind.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
fn f[T](x: &T[]) -> T { ret x.(0); }
1+
fn f[T](x: &[T]) -> T { ret x.(0); }
22

3-
fn g(act: fn(&int[]) -> int ) -> int { ret act(~[1, 2, 3]); }
3+
fn g(act: fn(&[int]) -> int ) -> int { ret act(~[1, 2, 3]); }
44

55
fn main() {
66
assert (g(f) == 1);
7-
let f1: fn(&str[]) -> str = f;
7+
let f1: fn(&[str]) -> str = f;
88
assert (f1(~["x", "y", "z"]) == "x");
9-
}
9+
}

0 commit comments

Comments
 (0)