diff options
Diffstat (limited to 'src/rustc')
28 files changed, 165 insertions, 145 deletions
diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index b9283745107..c56cf30d689 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -539,7 +539,7 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str { // gas doesn't! fn sanitize(s: ~str) -> ~str { let mut result = ~""; - do str::chars_iter(s) |c| { + for str::chars_each(s) |c| { match c { '@' => result += ~"_sbox_", '~' => result += ~"_ubox_", diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index be974cb75b5..937745eb3f6 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -99,8 +99,8 @@ fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> ~str { fn set_crate_data(cstore: cstore, cnum: ast::crate_num, data: crate_metadata) { p(cstore).metas.insert(cnum, data); - do vec::iter(decoder::get_crate_module_paths(cstore.intr, data)) |dp| { - let (did, path) = dp; + for vec::each(decoder::get_crate_module_paths(cstore.intr, data)) |dp| { + let (did, path) = *dp; let d = {crate: cnum, node: did.node}; p(cstore).mod_path_map.insert(d, @path); } diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 6b8a28235de..86ec0fe8747 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -267,7 +267,9 @@ fn encode_path(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: ast_map::path, do ebml_w.wr_tag(tag_path) { ebml_w.wr_tagged_u32(tag_path_len, (vec::len(path) + 1u) as u32); - do vec::iter(path) |pe| { encode_path_elt(ecx, ebml_w, pe); } + for vec::each(path) |pe| { + encode_path_elt(ecx, ebml_w, *pe); + } encode_path_elt(ecx, ebml_w, name); } } @@ -768,7 +770,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item, // written. Here, we output the *real* type signatures. I feel like // maybe we should only ever handle the real type signatures. for vec::each(ms) |m| { - let ty_m = ast_util::trait_method_to_ty_method(m); + let ty_m = ast_util::trait_method_to_ty_method(*m); if ty_m.self_ty.node != ast::sty_static { loop; } vec::push(*index, {val: ty_m.id, pos: ebml_w.writer.tell()}); diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index 6dc9810e296..df67749bc08 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -366,7 +366,7 @@ fn enc_ty_fn(w: io::Writer, cx: @ctxt, ft: ty::FnTy) { fn enc_bounds(w: io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) { for vec::each(*bs) |bound| { - match bound { + match *bound { ty::bound_send => w.write_char('S'), ty::bound_copy => w.write_char('C'), ty::bound_const => w.write_char('K'), diff --git a/src/rustc/middle/capture.rs b/src/rustc/middle/capture.rs index 28b86f66528..094e7e03a82 100644 --- a/src/rustc/middle/capture.rs +++ b/src/rustc/middle/capture.rs @@ -108,16 +108,16 @@ fn compute_capture_vars(tcx: ty::ctxt, implicit_mode = cap_copy; } - do vec::iter(*freevars) |fvar| { + for vec::each(*freevars) |fvar| { let fvar_def_id = ast_util::def_id_of_def(fvar.def).node; match cap_map.find(fvar_def_id) { - option::Some(_) => { /* was explicitly named, do nothing */ } - option::None => { - cap_map.insert(fvar_def_id, {def:fvar.def, - span: fvar.span, - cap_item: None, - mode:implicit_mode}); - } + option::Some(_) => { /* was explicitly named, do nothing */ } + option::None => { + cap_map.insert(fvar_def_id, {def:fvar.def, + span: fvar.span, + cap_item: None, + mode:implicit_mode}); + } } } diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index e81c8f967e0..cafecf52761 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -211,7 +211,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, }; let ty = ty::node_id_to_type(cx.tcx, id); - chk(cx, fn_id, Some(fv), is_move, ty, fv.span); + chk(cx, fn_id, Some(*fv), is_move, ty, fv.span); } } @@ -228,7 +228,7 @@ fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) { fn check_arm(a: arm, cx: ctx, v: visit::vt<ctx>) { for vec::each(a.pats) |p| { - do pat_util::pat_bindings(cx.tcx.def_map, p) |mode, id, span, _path| { + do pat_util::pat_bindings(cx.tcx.def_map, *p) |mode, id, span, _pth| { if mode == bind_by_value { let t = ty::node_id_to_type(cx.tcx, id); let reason = "consider binding with `ref` or `move` instead"; diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 561adce3150..faba978eef5 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -124,13 +124,13 @@ fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export. // An option identifying a branch (either a literal, a enum variant or a // range) -enum opt { +enum Opt { lit(@ast::expr), var(/* disr val */int, /* variant dids */{enm: def_id, var: def_id}), range(@ast::expr, @ast::expr) } -fn opt_eq(tcx: ty::ctxt, a: opt, b: opt) -> bool { - match (a, b) { +fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool { + match (*a, *b) { (lit(a), lit(b)) => const_eval::compare_lit_exprs(tcx, a, b) == 0, (range(a1, a2), range(b1, b2)) => { const_eval::compare_lit_exprs(tcx, a1, b1) == 0 && @@ -145,11 +145,11 @@ enum opt_result { single_result(Result), range_result(Result, Result), } -fn trans_opt(bcx: block, o: opt) -> opt_result { +fn trans_opt(bcx: block, o: &Opt) -> opt_result { let _icx = bcx.insn_ctxt("alt::trans_opt"); let ccx = bcx.ccx(); let mut bcx = bcx; - match o { + match *o { lit(lit_expr) => { let datumblock = expr::trans_to_datum(bcx, lit_expr); return single_result(datumblock.to_result()); @@ -164,7 +164,7 @@ fn trans_opt(bcx: block, o: opt) -> opt_result { } } -fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> opt { +fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> Opt { let vdef = ast_util::variant_def_ids(tcx.def_map.get(pat_id)); let variants = ty::enum_variants(tcx, vdef.enm); for vec::each(*variants) |v| { @@ -337,7 +337,7 @@ fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r], } } -fn enter_opt(bcx: block, m: &[@Match/&r], opt: opt, col: uint, +fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, variant_size: uint, val: ValueRef) -> ~[@Match/&r] { @@ -353,7 +353,7 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: opt, col: uint, do enter_match(bcx, tcx.def_map, m, col, val) |p| { match p.node { ast::pat_enum(_, subpats) => { - if opt_eq(tcx, variant_opt(tcx, p.id), opt) { + if opt_eq(tcx, &variant_opt(tcx, p.id), opt) { Some(option::get_default(subpats, vec::from_elem(variant_size, dummy))) @@ -362,17 +362,17 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: opt, col: uint, } } ast::pat_ident(_, _, None) if pat_is_variant(tcx.def_map, p) => { - if opt_eq(tcx, variant_opt(tcx, p.id), opt) { + if opt_eq(tcx, &variant_opt(tcx, p.id), opt) { Some(~[]) } else { None } } ast::pat_lit(l) => { - if opt_eq(tcx, lit(l), opt) { Some(~[]) } else { None } + if opt_eq(tcx, &lit(l), opt) {Some(~[])} else {None} } ast::pat_range(l1, l2) => { - if opt_eq(tcx, range(l1, l2), opt) { Some(~[]) } else { None } + if opt_eq(tcx, &range(l1, l2), opt) {Some(~[])} else {None} } _ => { assert_is_binding_or_wild(bcx, p); @@ -397,7 +397,7 @@ fn enter_rec_or_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint, ast::pat_rec(fpats, _) | ast::pat_struct(_, fpats, _) => { let mut pats = ~[]; for vec::each(fields) |fname| { - match fpats.find(|p| p.ident == fname) { + match fpats.find(|p| p.ident == *fname) { None => vec::push(pats, dummy), Some(pat) => vec::push(pats, pat.pat) } @@ -487,9 +487,9 @@ fn enter_uniq(bcx: block, dm: DefMap, m: &[@Match/&r], } } -fn get_options(ccx: @crate_ctxt, m: &[@Match], col: uint) -> ~[opt] { - fn add_to_set(tcx: ty::ctxt, set: &DVec<opt>, val: opt) { - if set.any(|l| opt_eq(tcx, l, val)) {return;} +fn get_options(ccx: @crate_ctxt, m: &[@Match], col: uint) -> ~[Opt] { + fn add_to_set(tcx: ty::ctxt, set: &DVec<Opt>, val: Opt) { + if set.any(|l| opt_eq(tcx, &l, &val)) {return;} set.push(val); } @@ -628,12 +628,14 @@ fn pick_col(m: &[@Match]) -> uint { let scores = vec::to_mut(vec::from_elem(m[0].pats.len(), 0u)); for vec::each(m) |br| { let mut i = 0u; - for vec::each(br.pats) |p| { scores[i] += score(p); i += 1u; } + for vec::each(br.pats) |p| { scores[i] += score(*p); i += 1u; } } let mut max_score = 0u; let mut best_col = 0u; let mut i = 0u; for vec::each(scores) |score| { + let score = *score; + // Irrefutable columns always go first, they'd only be duplicated in // the branches. if score == 0u { return i; } @@ -959,7 +961,7 @@ fn compile_submatch(bcx: block, } } for vec::each(opts) |o| { - match o { + match *o { range(_, _) => { kind = compare; break } _ => () } @@ -1037,7 +1039,7 @@ fn compile_submatch(bcx: block, let mut size = 0u; let mut unpacked = ~[]; - match opt { + match *opt { var(_, vdef) => { let args = extract_variant_args(opt_cx, pat_id, vdef, val); size = args.vals.len(); @@ -1087,7 +1089,7 @@ fn trans_alt_inner(scope_cx: block, } let mut arm_datas = ~[], matches = ~[]; - for vec::each_ref(arms) |arm| { + for vec::each(arms) |arm| { let body = scope_block(bcx, arm.body.info(), ~"case_body"); // Create the bindings map, which is a mapping from each binding name @@ -1129,7 +1131,7 @@ fn trans_alt_inner(scope_cx: block, bindings_map: bindings_map}; vec::push(arm_datas, arm_data); for vec::each(arm.pats) |p| { - vec::push(matches, @Match {pats: ~[p], data: arm_data}); + vec::push(matches, @Match {pats: ~[*p], data: arm_data}); } } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index ef791cd5020..47afe477287 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -160,11 +160,7 @@ fn trans_foreign_call(cx: block, externs: HashMap<~str, ValueRef>, let n = args.len() as int; let llforeign: ValueRef = get_simple_extern_fn(cx, externs, llmod, name, n); - let mut call_args: ~[ValueRef] = ~[]; - for vec::each(args) |a| { - vec::push(call_args, a); - } - return Call(cx, llforeign, call_args); + return Call(cx, llforeign, args); } fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { @@ -599,7 +595,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, int::to_str(variant.disr_val, 10u)); AddCase(llswitch, C_int(ccx, variant.disr_val), variant_cx.llbb); let variant_cx = - iter_variant(variant_cx, llunion_a_ptr, variant, + iter_variant(variant_cx, llunion_a_ptr, *variant, substs.tps, tid, f); Br(variant_cx, next_cx.llbb); } @@ -748,7 +744,7 @@ fn need_invoke(bcx: block) -> bool { match cur.kind { block_scope(inf) => { for vec::each(inf.cleanups) |cleanup| { - match cleanup { + match *cleanup { clean(_, cleanup_type) | clean_temp(_, _, cleanup_type) => { if cleanup_type == normal_exit_and_unwind { return true; @@ -1020,9 +1016,9 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block { match d.node { ast::decl_local(locals) => { for vec::each(locals) |local| { - bcx = init_local(bcx, local); + bcx = init_local(bcx, *local); if cx.sess().opts.extra_debuginfo { - debuginfo::create_local_var(bcx, local); + debuginfo::create_local_var(bcx, *local); } } } @@ -1118,7 +1114,7 @@ fn trans_block_cleanups_(bcx: block, bcx.ccx().sess.opts.debugging_opts & session::no_landing_pads != 0; if bcx.unreachable && !no_lpads { return bcx; } let mut bcx = bcx; - do vec::riter(cleanups) |cu| { + for vec::reach(cleanups) |cu| { match cu { clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) => { // Some types don't need to be cleaned up during @@ -1235,7 +1231,9 @@ fn block_locals(b: ast::blk, it: fn(@ast::local)) { ast::stmt_decl(d, _) => { match d.node { ast::decl_local(locals) => { - for vec::each(locals) |local| { it(local); } + for vec::each(locals) |local| { + it(*local); + } } _ => {/* fall through */ } } @@ -1789,7 +1787,7 @@ fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def, match variant.node.kind { ast::tuple_variant_kind(args) if args.len() > 0 => { let llfn = get_item_val(ccx, variant.node.id); - trans_enum_variant(ccx, id, variant, args, disr_val, + trans_enum_variant(ccx, id, *variant, args, disr_val, degen, None, llfn); } ast::tuple_variant_kind(_) => { @@ -1910,7 +1908,9 @@ fn trans_trait(ccx: @crate_ctxt, tps: ~[ast::ty_param], // and control visibility. fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) { let _icx = ccx.insn_ctxt("trans_mod"); - for vec::each(m.items) |item| { trans_item(ccx, *item); } + for vec::each(m.items) |item| { + trans_item(ccx, **item); + } } fn get_pair_fn_ty(llpairty: TypeRef) -> TypeRef { @@ -2352,21 +2352,22 @@ fn push_rtcall(ccx: @crate_ctxt, name: ~str, did: ast::def_id) { fn gather_local_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) { visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{ visit_item: |item| match item.node { - ast::item_fn(*) => { - let attr_metas = attr::attr_metas( - attr::find_attrs_by_name(item.attrs, ~"rt")); - do vec::iter(attr_metas) |attr_meta| { - match attr::get_meta_item_list(attr_meta) { - Some(list) => { - let name = attr::get_meta_item_name(vec::head(list)); - push_rtcall(ccx, name, {crate: ast::local_crate, - node: item.id}); - } - None => () + ast::item_fn(*) => { + let attr_metas = attr::attr_metas( + attr::find_attrs_by_name(item.attrs, ~"rt")); + for vec::each(attr_metas) |attr_meta| { + match attr::get_meta_item_list(*attr_meta) { + Some(list) => { + let head = vec::head(list); + let name = attr::get_meta_item_name(head); + push_rtcall(ccx, name, {crate: ast::local_crate, + node: item.id}); + } + None => () + } } } - } - _ => () + _ => () }, ..*visit::default_simple_visitor() })); @@ -2413,8 +2414,8 @@ fn gather_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) { let expected_rtcalls = ~[~"exchange_free", ~"exchange_malloc", ~"fail_", ~"free", ~"malloc"]; for vec::each(expected_rtcalls) |name| { - if !ccx.rtcalls.contains_key(name) { - fail fmt!("no definition for runtime call %s", name); + if !ccx.rtcalls.contains_key(*name) { + fail fmt!("no definition for runtime call %s", *name); } } } diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index acf0fcef966..c669dcfbb0d 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -435,7 +435,7 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { // XXX: Use a small-vector optimization to avoid allocations here. fn GEPi(cx: block, base: ValueRef, ixs: &[uint]) -> ValueRef { let mut v: ~[ValueRef] = ~[]; - for vec::each(ixs) |i| { vec::push(v, C_i32(i as i32)); } + for vec::each(ixs) |i| { vec::push(v, C_i32(*i as i32)); } count_insn(cx, "gepi"); return InBoundsGEP(cx, base, v); } diff --git a/src/rustc/middle/trans/callee.rs b/src/rustc/middle/trans/callee.rs index 4c33bd2b432..ea00d5aa467 100644 --- a/src/rustc/middle/trans/callee.rs +++ b/src/rustc/middle/trans/callee.rs @@ -450,7 +450,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t, match args { ArgExprs(arg_exprs) => { let last = arg_exprs.len() - 1u; - do vec::iteri(arg_exprs) |i, arg_expr| { + for vec::eachi(arg_exprs) |i, arg_expr| { let arg_val = unpack_result!(bcx, { trans_arg_expr(bcx, arg_tys[i], arg_expr, &mut temp_cleanups, if i == last { ret_flag } else { None }) @@ -466,8 +466,8 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t, // now that all arguments have been successfully built, we can revoke any // temporary cleanups, as they are only needed if argument construction // should fail (for example, cleanup of copy mode args). - do vec::iter(temp_cleanups) |c| { - revoke_clean(bcx, c) + for vec::each(temp_cleanups) |c| { + revoke_clean(bcx, *c) } return {bcx: bcx, args: llargs, retslot: llretslot}; diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 1ba8e22607a..7bc97551e6e 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -209,7 +209,7 @@ fn store_environment(bcx: block, // Copy expr values into boxed bindings. let mut bcx = bcx; - do vec::iteri(bound_values) |i, bv| { + for vec::eachi(bound_values) |i, bv| { debug!("Copy %s into closure", bv.to_str(ccx)); if !ccx.sess.no_asm_comments() { @@ -232,7 +232,9 @@ fn store_environment(bcx: block, } } - for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, cleanup); } + for vec::each(temp_cleanups) |cleanup| { + revoke_clean(bcx, *cleanup); + } return {llbox: llbox, cdata_ty: cdata_ty, bcx: bcx}; } @@ -251,8 +253,8 @@ fn build_closure(bcx0: block, // Package up the captured upvars let mut env_vals = ~[]; - do vec::iter(cap_vars) |cap_var| { - debug!("Building closure: captured variable %?", cap_var); + for vec::each(cap_vars) |cap_var| { + debug!("Building closure: captured variable %?", *cap_var); let datum = expr::trans_local_var(bcx, id, cap_var.def); match cap_var.mode { capture::cap_ref => { @@ -316,7 +318,7 @@ fn load_environment(fcx: fn_ctxt, // Populate the upvars from the environment. let mut i = 0u; - do vec::iter(cap_vars) |cap_var| { + for vec::each(cap_vars) |cap_var| { match cap_var.mode { capture::cap_drop => { /* ignore */ } _ => { diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index e6256772666..ee05a3bb4de 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -1175,11 +1175,13 @@ fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef { fn path_str(sess: session::session, p: path) -> ~str { let mut r = ~"", first = true; for vec::each(p) |e| { - match e { ast_map::path_name(s) | ast_map::path_mod(s) => { - if first { first = false; } - else { r += ~"::"; } - r += sess.str_of(s); - } } + match *e { + ast_map::path_name(s) | ast_map::path_mod(s) => { + if first { first = false; } + else { r += ~"::"; } + r += sess.str_of(s); + } + } } r } @@ -1269,8 +1271,8 @@ fn find_vtable(tcx: ty::ctxt, ps: ¶m_substs, // somewhat awkward for vec::each(*ps.bounds) |bounds| { if i >= n_param { break; } - for vec::each(*bounds) |bound| { - match bound { ty::bound_trait(_) => vtable_off += 1u, _ => () } + for vec::each(**bounds) |bound| { + match *bound { ty::bound_trait(_) => vtable_off += 1u, _ => () } } i += 1u; } diff --git a/src/rustc/middle/trans/controlflow.rs b/src/rustc/middle/trans/controlflow.rs index 1affa18a683..9570f37df75 100644 --- a/src/rustc/middle/trans/controlflow.rs +++ b/src/rustc/middle/trans/controlflow.rs @@ -13,7 +13,7 @@ fn trans_block(bcx: block, b: ast::blk, dest: expr::Dest) -> block { }; for vec::each(b.node.stmts) |s| { debuginfo::update_source_pos(bcx, b.span); - bcx = trans_stmt(bcx, *s); + bcx = trans_stmt(bcx, **s); } match b.node.expr { Some(e) => { @@ -85,7 +85,7 @@ fn join_blocks(parent_bcx: block, in_cxs: ~[block]) -> block { let mut reachable = false; for vec::each(in_cxs) |bcx| { if !bcx.unreachable { - Br(bcx, out.llbb); + Br(*bcx, out.llbb); reachable = true; } } diff --git a/src/rustc/middle/trans/expr.rs b/src/rustc/middle/trans/expr.rs index 303e10ce818..c5b31fe5492 100644 --- a/src/rustc/middle/trans/expr.rs +++ b/src/rustc/middle/trans/expr.rs @@ -1027,7 +1027,9 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: Dest) -> block { let mut bcx = bcx; let addr = match dest { Ignore => { - for vec::each(elts) |ex| { bcx = trans_into(bcx, ex, Ignore); } + for vec::each(elts) |ex| { + bcx = trans_into(bcx, *ex, Ignore); + } return bcx; } SaveIn(pos) => pos, @@ -1040,7 +1042,9 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: Dest) -> block { add_clean_temp_mem(bcx, dest, e_ty); vec::push(temp_cleanups, dest); } - for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, cleanup); } + for vec::each(temp_cleanups) |cleanup| { + revoke_clean(bcx, *cleanup); + } return bcx; } diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index b97fa54588c..cd762f135bb 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -165,9 +165,9 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } else { let mut field_off = off; for vec::each(tys) |ty| { - field_off = align(field_off, ty); - classify(ty, cls, i, field_off); - field_off += ty_size(ty); + field_off = align(field_off, *ty); + classify(*ty, cls, i, field_off); + field_off += ty_size(*ty); } } } @@ -283,7 +283,7 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef { fn llvec_len(cls: ~[x86_64_reg_class]) -> uint { let mut len = 1u; for vec::each(cls) |c| { - if c != sseup_class { + if *c != sseup_class { break; } len += 1u; @@ -377,7 +377,7 @@ fn x86_64_tys(atys: ~[TypeRef], let mut arg_tys = ~[]; let mut attrs = ~[]; for vec::each(atys) |t| { - let (ty, attr) = x86_64_ty(t, is_pass_byval, ByValAttribute); + let (ty, attr) = x86_64_ty(*t, is_pass_byval, ByValAttribute); vec::push(arg_tys, ty); vec::push(attrs, attr); } @@ -410,7 +410,7 @@ fn decl_x86_64_fn(tys: x86_64_tys, let fnty = T_fn(atys, rty); let llfn = decl(fnty); - do vec::iteri(tys.attrs) |i, a| { + for vec::eachi(tys.attrs) |i, a| { match a { option::Some(attr) => { let llarg = get_param(llfn, i); @@ -640,7 +640,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, let _icx = bcx.insn_ctxt("foreign::shim::build_ret"); match tys.x86_64_tys { Some(x86_64) => { - do vec::iteri(x86_64.attrs) |i, a| { + for vec::eachi(x86_64.attrs) |i, a| { match a { Some(attr) => { llvm::LLVMAddInstrAttribute( @@ -771,9 +771,9 @@ fn trans_foreign_mod(ccx: @crate_ctxt, let tys = c_stack_tys(ccx, id); if attr::attrs_contains_name(foreign_item.attrs, ~"rust_stack") { - build_direct_fn(ccx, llwrapfn, foreign_item, tys, cc); + build_direct_fn(ccx, llwrapfn, *foreign_item, tys, cc); } else { - let llshimfn = build_shim_fn(ccx, foreign_item, tys, cc); + let llshimfn = build_shim_fn(ccx, *foreign_item, tys, cc); build_wrap_fn(ccx, tys, llshimfn, llwrapfn); } } else { diff --git a/src/rustc/middle/trans/meth.rs b/src/rustc/middle/trans/meth.rs index a87ae02f8d2..d7a689c5c92 100644 --- a/src/rustc/middle/trans/meth.rs +++ b/src/rustc/middle/trans/meth.rs @@ -35,7 +35,7 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident, if method.tps.len() == 0u { let llfn = get_item_val(ccx, method.id); let path = vec::append_one(sub_path, path_name(method.ident)); - trans_method(ccx, path, method, None, llfn); + trans_method(ccx, path, *method, None, llfn); } } } diff --git a/src/rustc/middle/trans/monomorphize.rs b/src/rustc/middle/trans/monomorphize.rs index 243b0b96fa3..fe5b1115ed8 100644 --- a/src/rustc/middle/trans/monomorphize.rs +++ b/src/rustc/middle/trans/monomorphize.rs @@ -244,7 +244,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], vec::map2(*bounds, substs, |bounds, subst| { let mut v = ~[]; for vec::each(*bounds) |bound| { - match bound { + match *bound { ty::bound_trait(_) => { vec::push(v, meth::vtable_id(ccx, vts[i])); i += 1u; diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs index 061b260bfbb..d284cd840f1 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -54,7 +54,9 @@ fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool { fn traverse_export(cx: ctx, exp_id: node_id) { do option::iter(cx.exp_map.find(exp_id)) |defs| { - for vec::each(defs) |def| { traverse_def_id(cx, def.id); } + for vec::each(defs) |def| { + traverse_def_id(cx, def.id); + } } } @@ -82,7 +84,9 @@ fn traverse_def_id(cx: ctx, did: def_id) { fn traverse_public_mod(cx: ctx, m: _mod) { if !traverse_exports(cx, m.view_items) { // No exports, so every local item is exported - for vec::each(m.items) |item| { traverse_public_item(cx, item); } + for vec::each(m.items) |item| { + traverse_public_item(cx, *item); + } } } @@ -93,7 +97,9 @@ fn traverse_public_item(cx: ctx, item: @item) { item_mod(m) => traverse_public_mod(cx, m), item_foreign_mod(nm) => { if !traverse_exports(cx, nm.view_items) { - for vec::each(nm.items) |item| { cx.rmap.insert(item.id, ()); } + for vec::each(nm.items) |item| { + cx.rmap.insert(item.id, ()); + } } } item_fn(_, _, tps, blk) => { diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index b40afb6dd44..44d4128b388 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -323,7 +323,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { ty::ty_tup(elts) => { let mut s = ~[shape_struct], sub = ~[]; for vec::each(elts) |elt| { - sub += shape_of(ccx, elt); + sub += shape_of(ccx, *elt); } add_substr(s, sub); s @@ -376,7 +376,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { fn shape_of_variant(ccx: @crate_ctxt, v: ty::variant_info) -> ~[u8] { let mut s = ~[]; - for vec::each(v.args) |t| { s += shape_of(ccx, t); } + for vec::each(v.args) |t| { s += shape_of(ccx, *t); } return s; } @@ -391,10 +391,10 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { while i < ccx.shape_cx.tag_order.len() { let {did, substs} = ccx.shape_cx.tag_order[i]; let variants = @ty::substd_enum_variants(ccx.tcx, did, &substs); - do vec::iter(*variants) |v| { + for vec::each(*variants) |v| { offsets += ~[vec::len(data) as u16]; - let variant_shape = shape_of_variant(ccx, v); + let variant_shape = shape_of_variant(ccx, *v); add_substr(data, variant_shape); let zname = str::to_bytes(ccx.sess.str_of(v.name)) + ~[0u8]; @@ -435,7 +435,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { let lv = largest_variants(ccx, variants); add_u16(lv_table, vec::len(lv) as u16); - for vec::each(lv) |v| { add_u16(lv_table, v as u16); } + for vec::each(lv) |v| { add_u16(lv_table, *v as u16); } // Determine whether the enum has dynamic size. assert !vec::any(*variants, |v| { @@ -482,13 +482,13 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { let mut bounded = true; let mut min_size = 0u, min_align = 0u; for vec::each(variant.args) |elem_t| { - if ty::type_has_params(elem_t) { + if ty::type_has_params(*elem_t) { // NB: We could do better here; this causes us to // conservatively assume that (int, T) has minimum size 0, // when in fact it has minimum size sizeof(int). bounded = false; } else { - let llty = type_of::type_of(ccx, elem_t); + let llty = type_of::type_of(ccx, *elem_t); min_size += llsize_of_real(ccx, llty); min_align += llalign_of_pref(ccx, llty); } @@ -553,8 +553,8 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { for vec::each(largest_variants) |vid| { // We increment a "virtual data pointer" to compute the size. let mut lltys = ~[]; - for vec::each(variants[vid].args) |typ| { - lltys += ~[type_of::type_of(ccx, typ)]; + for vec::each(variants[*vid].args) |typ| { + lltys += ~[type_of::type_of(ccx, *typ)]; } let llty = trans::common::T_struct(lltys); diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index c0e695cbee1..8829257c33d 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -335,7 +335,7 @@ fn write_content(bcx: block, vec::push(temp_cleanups, lleltptr); } for vec::each(temp_cleanups) |cleanup| { - revoke_clean(bcx, cleanup); + revoke_clean(bcx, *cleanup); } } } @@ -373,7 +373,7 @@ fn write_content(bcx: block, } for vec::each(temp_cleanups) |cleanup| { - revoke_clean(bcx, cleanup); + revoke_clean(bcx, *cleanup); } return bcx; diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index 8c4f01701f0..fa523a4ab9e 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -158,7 +158,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { ty::ty_tup(elts) => { let mut tys = ~[]; for vec::each(elts) |elt| { - vec::push(tys, type_of(cx, elt)); + vec::push(tys, type_of(cx, *elt)); } T_struct(tys) } diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index 0975c8f4d8a..ba99c8e3967 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -118,7 +118,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) fn type_needs(cx: ctx, use_: uint, ty: ty::t) { // Optimization -- don't descend type if all params already have this use - for vec::each_mut_ref(cx.uses) |u| { + for vec::each_mut(cx.uses) |u| { if *u & use_ != use_ { type_needs_inner(cx, use_, ty, @Nil); return; @@ -144,7 +144,7 @@ fn type_needs_inner(cx: ctx, use_: uint, ty: ty::t, let seen = @Cons(did, enums_seen); for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) |v| { for vec::each(v.args) |aty| { - let t = ty::subst(cx.ccx.tcx, &substs, aty); + let t = ty::subst(cx.ccx.tcx, &substs, *aty); type_needs_inner(cx, use_, t, seen); } } @@ -247,14 +247,16 @@ fn mark_for_expr(cx: ctx, e: @expr) { node_type_needs(cx, use_tydesc, val.id); } expr_call(f, _, _) => { - vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)), |a| { - match a.mode { - expl(by_move) | expl(by_copy) | expl(by_val) => { - type_needs(cx, use_repr, a.ty); + for vec::each( + ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)) + ) |a| { + match a.mode { + expl(by_move) | expl(by_copy) | expl(by_val) => { + type_needs(cx, use_repr, a.ty); + } + _ => () } - _ => () - } - }) + } } expr_match(*) | expr_block(_) | expr_if(*) | expr_while(*) | expr_fail(_) | expr_break(_) | expr_again(_) | diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 78a5485ebae..bae64f02fcc 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -774,7 +774,7 @@ impl FnVid : to_bytes::IterBytes { fn param_bounds_to_kind(bounds: param_bounds) -> kind { let mut kind = kind_noncopyable(); for vec::each(*bounds) |bound| { - match bound { + match *bound { bound_copy => { kind = raise_kind(kind, kind_implicitly_copyable()); } @@ -1615,9 +1615,9 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool { // Any class with a dtor needs a drop option::is_some(ty_dtor(cx, did)) || { for vec::each(ty::class_items_as_fields(cx, did, substs)) |f| { - if type_needs_drop(cx, f.mt.ty) { accum = true; } - } - accum + if type_needs_drop(cx, f.mt.ty) { accum = true; } + } + accum } } ty_tup(elts) => { @@ -2682,7 +2682,7 @@ pure fn hash_type_structure(st: &sty) -> uint { } pure fn hash_subtys(id: uint, subtys: ~[t]) -> uint { let mut h = id; - for vec::each(subtys) |s| { h = (h << 2u) + type_id(s) } + for vec::each(subtys) |s| { h = (h << 2u) + type_id(*s) } h } pure fn hash_substs(h: uint, substs: &substs) -> uint { diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 2fb7b8a4890..b9218c064f4 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -57,7 +57,6 @@ use std::smallintmap; use std::map; use std::map::{HashMap, int_hash}; use std::serialization::{serialize_uint, deserialize_uint}; -use vec::each; use syntax::print::pprust::*; use util::ppaux::{ty_to_str, tys_to_str, region_to_str, bound_region_to_str, vstore_to_str, expr_repr}; diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index 8eb8f06a3ef..b37e8d54789 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -293,7 +293,7 @@ impl LookupContext { let mut next_bound_idx = 0; // count only trait bounds let bounds = tcx.ty_param_bounds.get(param_ty.def_id.node); for vec::each(*bounds) |bound| { - let bound_t = match bound { + let bound_t = match *bound { ty::bound_trait(bound_t) => bound_t, ty::bound_copy | ty::bound_send | diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index 24c505d045d..f3aae4dad3d 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -49,7 +49,7 @@ fn lookup_vtables(fcx: @fn_ctxt, let mut result = ~[], i = 0u; for substs.tps.each |ty| { for vec::each(*bounds[i]) |bound| { - match bound { + match *bound { ty::bound_trait(i_ty) => { let i_ty = ty::subst(tcx, substs, i_ty); vec::push(result, lookup_vtable(fcx, expr, ty, i_ty, @@ -122,7 +122,7 @@ fn lookup_vtable(fcx: @fn_ctxt, ty::ty_param({idx: n, def_id: did}) => { let mut n_bound = 0; for vec::each(*tcx.ty_param_bounds.get(did.node)) |bound| { - match bound { + match *bound { ty::bound_send | ty::bound_copy | ty::bound_const | ty::bound_owned => { /* ignore */ @@ -215,7 +215,7 @@ fn lookup_vtable(fcx: @fn_ctxt, // unify it with trait_ty in order to get all // the ty vars sorted out. for vec::each(ty::impl_traits(tcx, im.did)) |of_ty| { - match ty::get(of_ty).sty { + match ty::get(*of_ty).sty { ty::ty_trait(id, _, _) => { // Not the trait we're looking for if id != trait_id { loop; } @@ -271,8 +271,8 @@ fn lookup_vtable(fcx: @fn_ctxt, debug!("(checking vtable) @2 relating trait \ ty %s to of_ty %s", fcx.infcx().ty_to_str(trait_ty), - fcx.infcx().ty_to_str(of_ty)); - let of_ty = ty::subst(tcx, &substs, of_ty); + fcx.infcx().ty_to_str(*of_ty)); + let of_ty = ty::subst(tcx, &substs, *of_ty); relate_trait_tys(fcx, expr, trait_ty, of_ty); // Recall that trait_ty -- the trait type diff --git a/src/rustc/middle/typeck/check/writeback.rs b/src/rustc/middle/typeck/check/writeback.rs index d12095babb8..d7d6647e5bd 100644 --- a/src/rustc/middle/typeck/check/writeback.rs +++ b/src/rustc/middle/typeck/check/writeback.rs @@ -137,20 +137,20 @@ fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) { match e.node { ast::expr_fn(_, decl, _, _) | ast::expr_fn_block(decl, _, _) => { - do vec::iter(decl.inputs) |input| { - let r_ty = resolve_type_vars_for_node(wbcx, e.span, input.id); - - // Just in case we never constrained the mode to anything, - // constrain it to the default for the type in question. - match (r_ty, input.mode) { - (Some(t), ast::infer(_)) => { - let tcx = wbcx.fcx.ccx.tcx; - let m_def = ty::default_arg_mode_for_ty(tcx, t); - ty::set_default_mode(tcx, input.mode, m_def); + for vec::each(decl.inputs) |input| { + let r_ty = resolve_type_vars_for_node(wbcx, e.span, input.id); + + // Just in case we never constrained the mode to anything, + // constrain it to the default for the type in question. + match (r_ty, input.mode) { + (Some(t), ast::infer(_)) => { + let tcx = wbcx.fcx.ccx.tcx; + let m_def = ty::default_arg_mode_for_ty(tcx, t); + ty::set_default_mode(tcx, input.mode, m_def); + } + _ => () } - _ => () - } - } + } } ast::expr_binary(*) | ast::expr_unary(*) | ast::expr_assign_op(*) diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index cf8ed6315ca..ef557ebfa0d 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -363,7 +363,7 @@ fn check_methods_against_trait(ccx: @crate_ctxt, Some({mty: impl_m, span, _}) => { compare_impl_method( ccx.tcx, span, impl_m, vec::len(tps), - trait_m, tpt.substs, selfty); + *trait_m, tpt.substs, selfty); } None => { // If we couldn't find an implementation for trait_m in |
