Skip to content

Commit af21a27

Browse files
ericktgraydon
authored andcommitted
Port the compiler to the expr foo::<T> syntax.
1 parent d9327a6 commit af21a27

37 files changed

+335
-329
lines changed

src/comp/driver/rustc.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,25 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
150150
time(time_passes, "freevar finding",
151151
bind freevars::annotate_freevars(sess, d, crate));
152152
let ty_cx = ty::mk_ctxt(sess, d, ast_map, freevars);
153-
time[()](time_passes, "typechecking",
153+
time::<()>(time_passes, "typechecking",
154154
bind typeck::check_crate(ty_cx, crate));
155-
time[()](time_passes, "alt checking",
155+
time::<()>(time_passes, "alt checking",
156156
bind middle::check_alt::check_crate(ty_cx, crate));
157157
if sess.get_opts().run_typestate {
158158
time(time_passes, "typestate checking",
159159
bind middle::tstate::ck::check_crate(ty_cx, crate));
160160
}
161161
time(time_passes, "alias checking",
162162
bind middle::alias::check_crate(ty_cx, crate));
163-
time[()](time_passes, "kind checking",
163+
time::<()>(time_passes, "kind checking",
164164
bind kind::check_crate(ty_cx, crate));
165165
if sess.get_opts().no_trans { ret; }
166166
let llmod =
167-
time[llvm::llvm::ModuleRef](time_passes, "translation",
167+
time::<llvm::llvm::ModuleRef>(time_passes, "translation",
168168
bind trans::trans_crate(sess, crate,
169169
ty_cx, output,
170170
ast_map));
171-
time[()](time_passes, "LLVM passes",
171+
time::<()>(time_passes, "LLVM passes",
172172
bind link::write::run_passes(sess, llmod, output));
173173
}
174174

@@ -459,14 +459,14 @@ fn main(args: vec<str>) {
459459
}
460460
let sopts = build_session_options(binary, match, binary_dir);
461461
let sess = build_session(sopts);
462-
let n_inputs = vec::len[str](match.free);
462+
let n_inputs = vec::len::<str>(match.free);
463463
let output_file = getopts::opt_maybe_str(match, "o");
464464
let glue = opt_present(match, "glue");
465465
if glue {
466466
if n_inputs > 0u {
467467
sess.fatal("No input files allowed with --glue.");
468468
}
469-
let out = option::from_maybe[str]("glue.bc", output_file);
469+
let out = option::from_maybe::<str>("glue.bc", output_file);
470470
middle::trans::make_common_glue(sess, out);
471471
ret;
472472
}
@@ -479,26 +479,28 @@ fn main(args: vec<str>) {
479479
let saved_out_filename: str = "";
480480
let cfg = build_configuration(sess, binary, ifile);
481481
let expand =
482-
option::map[str,
483-
pp_mode](bind parse_pretty(sess, _),
484-
getopts::opt_default(match, "expand", "normal"));
482+
option::map::<str,
483+
pp_mode>(bind parse_pretty(sess, _),
484+
getopts::opt_default(match, "expand",
485+
"normal"));
485486
alt expand {
486-
some[pp_mode](ppm) {
487+
some::<pp_mode>(ppm) {
487488
pretty_print_input(sess, cfg, ifile, ppm, true);
488489
ret;
489490
}
490-
none[pp_mode]. {/* continue */ }
491+
none::<pp_mode>. {/* continue */ }
491492
}
492493
let pretty =
493-
option::map[str,
494-
pp_mode](bind parse_pretty(sess, _),
495-
getopts::opt_default(match, "pretty", "normal"));
494+
option::map::<str,
495+
pp_mode>(bind parse_pretty(sess, _),
496+
getopts::opt_default(match, "pretty",
497+
"normal"));
496498
alt pretty {
497-
some[pp_mode](ppm) {
499+
some::<pp_mode>(ppm) {
498500
pretty_print_input(sess, cfg, ifile, ppm, false);
499501
ret;
500502
}
501-
none[pp_mode]. {/* continue */ }
503+
none::<pp_mode>. {/* continue */ }
502504
}
503505
let ls = opt_present(match, "ls");
504506
if ls {

src/comp/front/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fn remove_meta_items_by_name(items: &[@ast::meta_item], name: str) ->
178178

179179
fn require_unique_names(sess: &session::session,
180180
metas: &[@ast::meta_item]) {
181-
let map = map::mk_hashmap[str, ()](str::hash, str::eq);
181+
let map = map::mk_hashmap::<str, ()>(str::hash, str::eq);
182182
for meta: @ast::meta_item in metas {
183183
let name = get_meta_item_name(meta);
184184
if map.contains_key(name) {

src/comp/lib/llvm.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,15 +1303,15 @@ obj builder(B: BuilderRef, terminated: @mutable bool,
13031303
ValueRef {
13041304
assert (!*terminated);
13051305
let phi = llvm::LLVMBuildPhi(B, Ty, str::buf(""));
1306-
assert (vec::len[ValueRef](vals) == vec::len[BasicBlockRef](bbs));
1306+
assert (vec::len::<ValueRef>(vals) == vec::len::<BasicBlockRef>(bbs));
13071307
llvm::LLVMAddIncoming(phi, vec::to_ptr(vals), vec::to_ptr(bbs),
13081308
vec::len(vals));
13091309
ret phi;
13101310
}
13111311

13121312
fn AddIncomingToPhi(phi: ValueRef, vals: &[ValueRef],
13131313
bbs: &[BasicBlockRef]) {
1314-
assert (vec::len[ValueRef](vals) == vec::len[BasicBlockRef](bbs));
1314+
assert (vec::len::<ValueRef>(vals) == vec::len::<BasicBlockRef>(bbs));
13151315
llvm::LLVMAddIncoming(phi, vec::to_ptr(vals), vec::to_ptr(bbs),
13161316
vec::len(vals));
13171317
}
@@ -1440,15 +1440,15 @@ obj type_names(type_names: std::map::hashmap<TypeRef, str>,
14401440
}
14411441

14421442
fn mk_type_names() -> type_names {
1443-
let nt = std::map::new_str_hash[TypeRef]();
1443+
let nt = std::map::new_str_hash::<TypeRef>();
14441444

14451445
fn hash(t: &TypeRef) -> uint { ret t as uint; }
14461446

14471447
fn eq(a: &TypeRef, b: &TypeRef) -> bool { ret a as uint == b as uint; }
14481448

14491449
let hasher: std::map::hashfn<TypeRef> = hash;
14501450
let eqer: std::map::eqfn<TypeRef> = eq;
1451-
let tn = std::map::mk_hashmap[TypeRef, str](hasher, eqer);
1451+
let tn = std::map::mk_hashmap::<TypeRef, str>(hasher, eqer);
14521452

14531453
ret type_names(tn, nt);
14541454
}
@@ -1503,7 +1503,7 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
15031503
let s = "fn(";
15041504
let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
15051505
let n_args: uint = llvm::LLVMCountParamTypes(ty);
1506-
let args: [TypeRef] = vec::init_elt[TypeRef](0 as TypeRef, n_args);
1506+
let args: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_args);
15071507
llvm::LLVMGetParamTypes(ty, vec::to_ptr(args));
15081508
s += tys_str(names, outer, args);
15091509
s += ") -> ";
@@ -1515,7 +1515,7 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
15151515
9 {
15161516
let s: str = "{";
15171517
let n_elts: uint = llvm::LLVMCountStructElementTypes(ty);
1518-
let elts: [TypeRef] = vec::init_elt[TypeRef](0 as TypeRef, n_elts);
1518+
let elts: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_elts);
15191519
llvm::LLVMGetStructElementTypes(ty, vec::to_ptr(elts));
15201520
s += tys_str(names, outer, elts);
15211521
s += "}";
@@ -1534,7 +1534,7 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
15341534
for tout: TypeRef in outer0 {
15351535
i += 1u;
15361536
if tout as int == ty as int {
1537-
let n: uint = vec::len[TypeRef](outer0) - i;
1537+
let n: uint = vec::len::<TypeRef>(outer0) - i;
15381538
ret "*\\" + std::int::str(n as int);
15391539
}
15401540
}

src/comp/metadata/creader.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export list_file_metadata;
3232
fn read_crates(sess: session::session, crate: &ast::crate) {
3333
let e =
3434
@{sess: sess,
35-
crate_cache: @std::map::new_str_hash[int](),
35+
crate_cache: @std::map::new_str_hash::<int>(),
3636
library_search_paths: sess.get_opts().library_search_paths,
3737
mutable next_crate_num: 1};
3838
let v =
@@ -186,7 +186,7 @@ fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
186186
fn get_metadata_section(filename: str) -> option::t<@[u8]> {
187187
let b = str::buf(filename);
188188
let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(b);
189-
if mb as int == 0 { ret option::none[@[u8]]; }
189+
if mb as int == 0 { ret option::none::<@[u8]>; }
190190
let of = mk_object_file(mb);
191191
let si = mk_section_iter(of.llof);
192192
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
@@ -196,11 +196,11 @@ fn get_metadata_section(filename: str) -> option::t<@[u8]> {
196196
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
197197
let csz = llvm::LLVMGetSectionSize(si.llsi);
198198
let cvbuf: *u8 = std::unsafe::reinterpret_cast(cbuf);
199-
ret option::some[@[u8]](@vec::unsafe::from_buf(cvbuf, csz));
199+
ret option::some::<@[u8]>(@vec::unsafe::from_buf(cvbuf, csz));
200200
}
201201
llvm::LLVMMoveToNextSection(si.llsi);
202202
}
203-
ret option::none[@[u8]];
203+
ret option::none::<@[u8]>;
204204
}
205205

206206
fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident,
@@ -249,7 +249,7 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
249249
log "resolving deps of external crate";
250250
// The map from crate numbers in the crate we're resolving to local crate
251251
// numbers
252-
let cnum_map = new_int_hash[ast::crate_num]();
252+
let cnum_map = new_int_hash::<ast::crate_num>();
253253
for dep: decoder::crate_dep in decoder::get_crate_deps(cdata) {
254254
let extrn_cnum = dep.cnum;
255255
let cname = dep.ident;

src/comp/metadata/cstore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ type use_crate_map = map::hashmap<ast::node_id, ast::crate_num>;
5252
fn p(cstore: &cstore) -> cstore_private { alt cstore { private(p) { p } } }
5353

5454
fn mk_cstore() -> cstore {
55-
let meta_cache = map::new_int_hash[crate_metadata]();
56-
let crate_map = map::new_int_hash[ast::crate_num]();
55+
let meta_cache = map::new_int_hash::<crate_metadata>();
56+
let crate_map = map::new_int_hash::<ast::crate_num>();
5757
ret private(@{metas: meta_cache,
5858
use_crate_map: crate_map,
5959
mutable used_crate_files: ~[],

src/comp/metadata/decoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn lookup_hash(d: &ebml::doc, eq_fn: fn(&[u8]) -> bool , hash: uint) ->
4848
let belt = tag_index_buckets_bucket_elt;
4949
for each elt: ebml::doc in ebml::tagged_docs(bucket, belt) {
5050
let pos = ebml::be_uint_from_bytes(elt.data, elt.start, 4u);
51-
if eq_fn(vec::slice[u8](*elt.data, elt.start + 4u, elt.end)) {
51+
if eq_fn(vec::slice::<u8>(*elt.data, elt.start + 4u, elt.end)) {
5252
result += ~[ebml::doc_at(d.data, pos)];
5353
}
5454
}
@@ -63,8 +63,8 @@ fn maybe_find_item(item_id: int, items: &ebml::doc) ->
6363
let eqer = bind eq_item(_, item_id);
6464
let found = lookup_hash(items, eqer, hash_node_id(item_id));
6565
if vec::len(found) == 0u {
66-
ret option::none[ebml::doc];
67-
} else { ret option::some[ebml::doc](found.(0)); }
66+
ret option::none::<ebml::doc>;
67+
} else { ret option::some::<ebml::doc>(found.(0)); }
6868
}
6969

7070
fn find_item(item_id: int, items: &ebml::doc) -> ebml::doc {
@@ -269,7 +269,7 @@ fn family_has_type_params(fam_ch: u8) -> bool {
269269
fn read_path(d: &ebml::doc) -> {path: str, pos: uint} {
270270
let desc = ebml::doc_data(d);
271271
let pos = ebml::be_uint_from_bytes(@desc, 0u, 4u);
272-
let pathbytes = vec::slice[u8](desc, 4u, vec::len[u8](desc));
272+
let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc));
273273
let path = str::unsafe_from_bytes(pathbytes);
274274
ret {path: path, pos: pos};
275275
}

src/comp/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn def_to_str(did: &def_id) -> str { ret #fmt("%d:%d", did.crate, did.node); }
176176

177177
fn encode_type_param_kinds(ebml_w: &ebml::writer, tps: &[ty_param]) {
178178
ebml::start_tag(ebml_w, tag_items_data_item_ty_param_kinds);
179-
ebml::write_vint(ebml_w.writer, vec::len[ty_param](tps));
179+
ebml::write_vint(ebml_w.writer, vec::len::<ty_param>(tps));
180180
for tp: ty_param in tps {
181181
let c = alt tp.kind {
182182
kind_unique. { 'u' }
@@ -236,7 +236,7 @@ fn encode_tag_variant_info(ecx: &@encode_ctxt, ebml_w: &ebml::writer,
236236
encode_tag_id(ebml_w, local_def(id));
237237
encode_type(ecx, ebml_w,
238238
node_id_to_monotype(ecx.ccx.tcx, variant.node.id));
239-
if vec::len[variant_arg](variant.node.args) > 0u {
239+
if vec::len::<variant_arg>(variant.node.args) > 0u {
240240
encode_symbol(ecx, ebml_w, variant.node.id);
241241
}
242242
encode_discriminant(ecx, ebml_w, variant.node.id);

src/comp/metadata/tydecode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn parse_constrs(st: @pstate, sd: str_def) -> [@ty::constr] {
7171
do {
7272
next(st);
7373
let one: @ty::constr =
74-
parse_constr[uint](st, sd, parse_constr_arg);
74+
parse_constr::<uint>(st, sd, parse_constr_arg);
7575
rslt += ~[one];
7676
} while peek(st) as char == ';'
7777
}
@@ -88,7 +88,7 @@ fn parse_ty_constrs(st: @pstate, sd: str_def) -> [@ty::type_constr] {
8888
do {
8989
next(st);
9090
let one: @ty::type_constr =
91-
parse_constr[path](st, sd, parse_ty_constr_arg);
91+
parse_constr::<path>(st, sd, parse_ty_constr_arg);
9292
rslt += ~[one];
9393
} while peek(st) as char == ';'
9494
}
@@ -406,14 +406,14 @@ fn parse_ty_fn(st: @pstate, sd: str_def) ->
406406
// Rust metadata parsing
407407
fn parse_def_id(buf: &[u8]) -> ast::def_id {
408408
let colon_idx = 0u;
409-
let len = vec::len[u8](buf);
409+
let len = vec::len::<u8>(buf);
410410
while colon_idx < len && buf.(colon_idx) != ':' as u8 { colon_idx += 1u; }
411411
if colon_idx == len {
412412
log_err "didn't find ':' when parsing def id";
413413
fail;
414414
}
415-
let crate_part = vec::slice[u8](buf, 0u, colon_idx);
416-
let def_part = vec::slice[u8](buf, colon_idx + 1u, len);
415+
let crate_part = vec::slice::<u8>(buf, 0u, colon_idx);
416+
let def_part = vec::slice::<u8>(buf, colon_idx + 1u, len);
417417

418418
let crate_part_vec = ~[];
419419
let def_part_vec = ~[];

src/comp/middle/alias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn check_crate(tcx: ty::ctxt, crate: &@ast::crate) {
4646
visit_item: bind visit_item(cx, _, _, _),
4747
visit_expr: bind visit_expr(cx, _, _, _),
4848
visit_decl: bind visit_decl(cx, _, _, _)
49-
with *visit::default_visitor[scope]()};
49+
with *visit::default_visitor::<scope>()};
5050
visit::visit_crate(*crate, @~[], visit::mk_vt(v));
5151
tcx.sess.abort_if_errors();
5252
}

src/comp/middle/ast_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ fn map_crate(c: &crate) -> map {
1818
// FIXME: This is using an adapter to convert the smallintmap
1919
// interface to the hashmap interface. It would be better to just
2020
// convert everything to use the smallintmap.
21-
let map = new_smallintmap_int_adapter[ast_node]();
21+
let map = new_smallintmap_int_adapter::<ast_node>();
2222

2323
let v_map =
2424
@{visit_item: bind map_item(map, _, _, _),
2525
visit_native_item: bind map_native_item(map, _, _, _),
2626
visit_expr: bind map_expr(map, _, _, _)
27-
with *visit::default_visitor[()]()};
27+
with *visit::default_visitor::<()>()};
2828
visit::visit_crate(c, (), visit::mk_vt(v_map));
2929
ret map;
3030
}
@@ -110,7 +110,7 @@ fn new_smallintmap_adapter<@K,
110110
}
111111
}
112112

113-
let map = smallintmap::mk[V]();
113+
let map = smallintmap::mk::<V>();
114114
ret adapter(map, key_idx, idx_key);
115115
}
116116

src/comp/middle/check_alt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn check_crate(tcx: &ty::ctxt, crate: &@crate) {
55
let v =
66
@{visit_expr: bind check_expr(tcx, _, _, _),
77
visit_local: bind check_local(tcx, _, _, _)
8-
with *visit::default_visitor[()]()};
8+
with *visit::default_visitor::<()>()};
99
visit::visit_crate(*crate, (), visit::mk_vt(v));
1010
tcx.sess.abort_if_errors();
1111
}

0 commit comments

Comments
 (0)