diff options
Diffstat (limited to 'src/rustc')
32 files changed, 250 insertions, 231 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..121b8e226ed 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_ref(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..a4b830c68dc 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_ref(path) |pe| { + encode_path_elt(ecx, ebml_w, *pe); + } encode_path_elt(ecx, ebml_w, name); } } @@ -737,7 +739,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item, encode_name(ecx, ebml_w, item.ident); encode_attributes(ebml_w, item.attrs); let mut i = 0u; - for vec::each(*ty::trait_methods(tcx, local_def(item.id))) |mty| { + for vec::each_ref(*ty::trait_methods(tcx, local_def(item.id))) |mty| { match ms[i] { required(ty_m) => { ebml_w.start_tag(tag_item_trait_method); @@ -767,8 +769,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item, // method info, we output static methods with type signatures as // 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); + for vec::each_ref(ms) |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()}); @@ -888,7 +890,7 @@ fn encode_index<T>(ebml_w: ebml::Writer, buckets: ~[@~[entry<T>]], for buckets.each |bucket| { vec::push(bucket_locs, ebml_w.writer.tell()); ebml_w.start_tag(tag_index_buckets_bucket); - for vec::each(*bucket) |elt| { + for vec::each_ref(*bucket) |elt| { ebml_w.start_tag(tag_index_buckets_bucket_elt); assert elt.pos < 0xffff_ffff; writer.write_be_u32(elt.pos as u32); diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index 6dc9810e296..049a37a99e5 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -365,8 +365,8 @@ 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 { + for vec::each_ref(*bs) |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..98ba9162851 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_ref(*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/check_alt.rs b/src/rustc/middle/check_alt.rs index 79dbcecbec4..af926046b42 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -274,7 +274,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option<ctor> { } let variants = ty::enum_variants(tcx, eid); if found.len() != (*variants).len() { - for vec::each(*variants) |v| { + for vec::each_ref(*variants) |v| { if !found.contains(variant(v.id)) { return Some(variant(v.id)); } diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index e81c8f967e0..392e3b4d55a 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -195,7 +195,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, // Iterate over any free variables that may not have appeared in the // capture list. Ensure that they too are of the appropriate kind. - for vec::each(*freevars::get_freevars(cx.tcx, fn_id)) |fv| { + for vec::each_ref(*freevars::get_freevars(cx.tcx, fn_id)) |fv| { let id = ast_util::def_id_of_def(fv.def).node; // skip over free variables that appear in the cap clause @@ -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); } } @@ -227,8 +227,8 @@ 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| { + for vec::each_ref(a.pats) |p| { + do pat_util::pat_bindings(cx.tcx.def_map, *p) |mode, id, span, _path| { 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/lint.rs b/src/rustc/middle/lint.rs index 8e22315ef6b..b62811eed3e 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -451,7 +451,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id, decl: ast::fn_decl) { let tys = vec::map(decl.inputs, |a| a.ty ); - for vec::each(vec::append_one(tys, decl.output)) |ty| { + for vec::each_ref(vec::append_one(tys, decl.output)) |ty| { match ty.node { ast::ty_path(_, id) => { match cx.def_map.get(id) { diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 1d32d4bc3dc..bdd59455787 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -4343,11 +4343,11 @@ impl Resolver { let rib = self.type_ribs.get_elt(i); match rib.kind { MethodRibKind(node_id, _) => - for vec::each(self.crate.node.module.items) |item| { + for vec::each_ref(self.crate.node.module.items) |item| { if item.id == node_id { match item.node { item_class(class_def, _) => { - for vec::each(class_def.fields) |field| { + for vec::each_ref(class_def.fields) |field| { match field.node.kind { syntax::ast::unnamed_field => {}, @@ -4360,7 +4360,7 @@ impl Resolver { } } } - for vec::each(class_def.methods) |method| { + for vec::each_ref(class_def.methods) |method| { if str::eq_slice(self.session.str_of(method.ident), name) { return true diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 561adce3150..b96990f24b8 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,10 +164,10 @@ 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| { + for vec::each_ref(*variants) |v| { if vdef.var == v.id { return var(v.disr_val, vdef); } } core::unreachable(); @@ -221,7 +221,7 @@ fn matches_to_str(bcx: block, m: &[@Match]) -> ~str { } fn has_nested_bindings(m: &[@Match], col: uint) -> bool { - for vec::each(m) |br| { + for vec::each_ref(m) |br| { match br.pats[col].node { ast::pat_ident(_, _, Some(_)) => return true, _ => () @@ -285,7 +285,7 @@ fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r], let _indenter = indenter(); let mut result = ~[]; - for vec::each(m) |br| { + for vec::each_ref(m) |br| { match e(br.pats[col]) { Some(sub) => { let pats = @@ -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); @@ -396,8 +396,8 @@ fn enter_rec_or_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint, match p.node { ast::pat_rec(fpats, _) | ast::pat_struct(_, fpats, _) => { let mut pats = ~[]; - for vec::each(fields) |fname| { - match fpats.find(|p| p.ident == fname) { + for vec::each_ref(fields) |fname| { + match fpats.find(|p| p.ident == *fname) { None => vec::push(pats, dummy), Some(pat) => vec::push(pats, pat.pat) } @@ -487,14 +487,14 @@ 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); } let found = DVec(); - for vec::each(m) |br| { + for vec::each_ref(m) |br| { let cur = br.pats[col]; if pat_is_variant(ccx.tcx.def_map, cur) { add_to_set(ccx.tcx, &found, variant_opt(ccx.tcx, cur.id)); @@ -544,7 +544,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, fn collect_record_or_struct_fields(m: &[@Match], col: uint) -> ~[ast::ident] { let mut fields: ~[ast::ident] = ~[]; - for vec::each(m) |br| { + for vec::each_ref(m) |br| { match br.pats[col].node { ast::pat_rec(fs, _) => extend(&mut fields, fs), ast::pat_struct(_, fs, _) => extend(&mut fields, fs), @@ -566,7 +566,7 @@ fn collect_record_or_struct_fields(m: &[@Match], col: uint) -> ~[ast::ident] { fn root_pats_as_necessary(bcx: block, m: &[@Match], col: uint, val: ValueRef) { - for vec::each(m) |br| { + for vec::each_ref(m) |br| { let pat_id = br.pats[col].id; match bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) { @@ -586,7 +586,7 @@ fn root_pats_as_necessary(bcx: block, m: &[@Match], } fn any_box_pat(m: &[@Match], col: uint) -> bool { - for vec::each(m) |br| { + for vec::each_ref(m) |br| { match br.pats[col].node { ast::pat_box(_) => return true, _ => () @@ -596,7 +596,7 @@ fn any_box_pat(m: &[@Match], col: uint) -> bool { } fn any_uniq_pat(m: &[@Match], col: uint) -> bool { - for vec::each(m) |br| { + for vec::each_ref(m) |br| { match br.pats[col].node { ast::pat_uniq(_) => return true, _ => () @@ -606,7 +606,7 @@ fn any_uniq_pat(m: &[@Match], col: uint) -> bool { } fn any_tup_pat(m: &[@Match], col: uint) -> bool { - for vec::each(m) |br| { + for vec::each_ref(m) |br| { match br.pats[col].node { ast::pat_tup(_) => return true, _ => () @@ -626,14 +626,16 @@ fn pick_col(m: &[@Match]) -> uint { } } let scores = vec::to_mut(vec::from_elem(m[0].pats.len(), 0u)); - for vec::each(m) |br| { + for vec::each_ref(m) |br| { let mut i = 0u; - for vec::each(br.pats) |p| { scores[i] += score(p); i += 1u; } + for vec::each_ref(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| { + for vec::each_ref(scores) |score| { + let score = *score; + // Irrefutable columns always go first, they'd only be duplicated in // the branches. if score == 0u { return i; } @@ -871,7 +873,7 @@ fn compile_submatch(bcx: block, vec::view(vals, col + 1u, vals.len())); let ccx = bcx.fcx.ccx; let mut pat_id = 0; - for vec::each(m) |br| { + for vec::each_ref(m) |br| { // Find a real id (we're adding placeholder wildcard patterns, but // each column is guaranteed to have at least one real pattern) if pat_id == 0 { pat_id = br.pats[col].id; } @@ -958,8 +960,8 @@ fn compile_submatch(bcx: block, } } } - for vec::each(opts) |o| { - match o { + for vec::each_ref(opts) |o| { + match *o { range(_, _) => { kind = compare; break } _ => () } @@ -980,7 +982,7 @@ fn compile_submatch(bcx: block, let mut i = 0u; // Compile subtrees for each option - for vec::each(opts) |opt| { + for vec::each_ref(opts) |opt| { i += 1u; let mut opt_cx = else_cx; if !exhaustive || i < len { @@ -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(); @@ -1128,8 +1130,8 @@ fn trans_alt_inner(scope_cx: block, arm: arm, 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}); + for vec::each_ref(arm.pats) |p| { + vec::push(matches, @Match {pats: ~[*p], data: arm_data}); } } @@ -1224,7 +1226,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, let tcx = bcx.tcx(); let pat_ty = node_id_type(bcx, pat.id); do expr::with_field_tys(tcx, pat_ty) |_has_dtor, field_tys| { - for vec::each(fields) |f| { + for vec::each_ref(fields) |f| { let ix = ty::field_idx_strict(tcx, f.ident, field_tys); let fldptr = GEPi(bcx, val, struct_field(ix)); bcx = bind_irrefutable_pat(bcx, f.pat, fldptr, make_copy); diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index ef791cd5020..28de3e55569 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 { @@ -532,7 +528,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, ty::ty_fn(ref fn_ty) => { let mut j = 0u; let v_id = variant.id; - for vec::each(fn_ty.sig.inputs) |a| { + for vec::each_ref(fn_ty.sig.inputs) |a| { let llfldp_a = GEP_enum(cx, a_tup, tid, v_id, tps, j); let ty_subst = ty::subst_tps(ccx.tcx, tps, a.ty); cx = f(cx, llfldp_a, ty_subst); @@ -592,14 +588,14 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, Unreachable(unr_cx); let llswitch = Switch(cx, lldiscrim_a, unr_cx.llbb, n_variants); let next_cx = sub_block(cx, ~"enum-iter-next"); - for vec::each(*variants) |variant| { + for vec::each_ref(*variants) |variant| { let variant_cx = sub_block(cx, ~"enum-iter-variant-" + 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); } @@ -747,8 +743,8 @@ fn need_invoke(bcx: block) -> bool { loop { match cur.kind { block_scope(inf) => { - for vec::each(inf.cleanups) |cleanup| { - match cleanup { + for vec::each_ref(inf.cleanups) |cleanup| { + match *cleanup { clean(_, cleanup_type) | clean_temp(_, _, cleanup_type) => { if cleanup_type == normal_exit_and_unwind { return true; @@ -1019,10 +1015,10 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block { ast::stmt_decl(d, _) => { match d.node { ast::decl_local(locals) => { - for vec::each(locals) |local| { - bcx = init_local(bcx, local); + for vec::each_ref(locals) |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 @@ -1230,12 +1226,14 @@ fn with_scope_datumblock(bcx: block, opt_node_info: Option<node_info>, } fn block_locals(b: ast::blk, it: fn(@ast::local)) { - for vec::each(b.node.stmts) |s| { + for vec::each_ref(b.node.stmts) |s| { match s.node { ast::stmt_decl(d, _) => { match d.node { ast::decl_local(locals) => { - for vec::each(locals) |local| { it(local); } + for vec::each_ref(locals) |local| { + it(*local); + } } _ => {/* fall through */ } } @@ -1464,7 +1462,7 @@ fn create_llargs_for_fn_args(cx: fn_ctxt, // Populate the llargs field of the function context with the ValueRefs // that we get from llvm::LLVMGetParam for each argument. - for vec::each(args) |arg| { + for vec::each_ref(args) |arg| { let llarg = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint); assert (llarg as int != 0); // Note that this uses local_mem even for things passed by value. @@ -1499,7 +1497,7 @@ fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: ~[ast::arg], _ => {} } - for vec::each(arg_tys) |arg| { + for vec::each_ref(arg_tys) |arg| { let id = args[arg_n].id; let argval = match fcx.llargs.get(id) { local_mem(v) => v, @@ -1782,14 +1780,14 @@ fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def, id: ast::node_id, tps: ~[ast::ty_param], degen: bool, path: @ast_map::path, vi: @~[ty::variant_info], i: &mut uint) { - for vec::each(enum_definition.variants) |variant| { + for vec::each_ref(enum_definition.variants) |variant| { let disr_val = vi[*i].disr_val; *i += 1; 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(_) => { @@ -1829,7 +1827,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { vec::append(*path, ~[path_name(item.ident)]), decl, body, llfndecl, no_self, None, item.id); } else { - for vec::each(body.node.stmts) |stmt| { + for vec::each_ref(body.node.stmts) |stmt| { match stmt.node { ast::stmt_decl(@{node: ast::decl_item(i), _}, _) => { trans_item(ccx, *i); @@ -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_ref(m.items) |item| { + trans_item(ccx, **item); + } } fn get_pair_fn_ty(llpairty: TypeRef) -> TypeRef { @@ -2236,7 +2236,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) { node: it.id}); let mut i = 0; let path = item_path(ccx, it); - for vec::each(enum_definition.variants) |variant| { + for vec::each_ref(enum_definition.variants) |variant| { let p = vec::append(path, ~[path_name(variant.node.name), path_name(special_idents::descrim)]); let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx)); @@ -2352,21 +2352,21 @@ 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_ref(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 => () + } } } - } - _ => () + _ => () }, ..*visit::default_simple_visitor() })); @@ -2412,9 +2412,9 @@ fn gather_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) { // for an rtcall. 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); + for vec::each_ref(expected_rtcalls) |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..6d687b3a8cd 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_ref(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..6db93f1cc93 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_ref(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..72b3d4d8dfd 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_ref(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_ref(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_ref(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..ba47aa64065 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -1174,12 +1174,14 @@ 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); - } } + for vec::each_ref(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); + } + } } r } @@ -1267,10 +1269,10 @@ fn find_vtable(tcx: ty::ctxt, ps: ¶m_substs, let mut vtable_off = n_bound, i = 0u; // Vtables are stored in a flat array, finding the right one is // somewhat awkward - for vec::each(*ps.bounds) |bounds| { + for vec::each_ref(*ps.bounds) |bounds| { if i >= n_param { break; } - for vec::each(*bounds) |bound| { - match bound { ty::bound_trait(_) => vtable_off += 1u, _ => () } + for vec::each_ref(**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..bb4314bc37a 100644 --- a/src/rustc/middle/trans/controlflow.rs +++ b/src/rustc/middle/trans/controlflow.rs @@ -11,9 +11,9 @@ fn trans_block(bcx: block, b: ast::blk, dest: expr::Dest) -> block { do block_locals(b) |local| { bcx = alloc_local(bcx, local); }; - for vec::each(b.node.stmts) |s| { + for vec::each_ref(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) => { @@ -83,9 +83,9 @@ fn trans_if(bcx: block, fn join_blocks(parent_bcx: block, in_cxs: ~[block]) -> block { let out = sub_block(parent_bcx, ~"join"); let mut reachable = false; - for vec::each(in_cxs) |bcx| { + for vec::each_ref(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..6ba2257d421 100644 --- a/src/rustc/middle/trans/expr.rs +++ b/src/rustc/middle/trans/expr.rs @@ -971,7 +971,7 @@ fn trans_rec_or_struct(bcx: block, Ignore => { // just evaluate the values for each field and drop them // on the floor - for vec::each(fields) |fld| { + for vec::each_ref(fields) |fld| { bcx = trans_into(bcx, fld.node.expr, Ignore); } return bcx; @@ -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_ref(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_ref(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..65f8dd6e493 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -164,10 +164,10 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { classify(T_i64(), cls, i, off); } 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); + for vec::each_ref(tys) |ty| { + field_off = align(field_off, *ty); + classify(*ty, cls, i, field_off); + field_off += ty_size(*ty); } } } @@ -282,8 +282,8 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { 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 { + for vec::each_ref(cls) |c| { + if *c != sseup_class { break; } len += 1u; @@ -376,8 +376,8 @@ 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); + for vec::each_ref(atys) |t| { + 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( @@ -762,7 +762,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, ast::foreign_abi_stdcall => lib::llvm::X86StdcallCallConv }; - for vec::each(foreign_mod.items) |foreign_item| { + for vec::each_ref(foreign_mod.items) |foreign_item| { match foreign_item.node { ast::foreign_item_fn(*) => { let id = foreign_item.id; @@ -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..d42d7cff94d 100644 --- a/src/rustc/middle/trans/meth.rs +++ b/src/rustc/middle/trans/meth.rs @@ -31,11 +31,11 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident, let _icx = ccx.insn_ctxt("impl::trans_impl"); if tps.len() > 0u { return; } let sub_path = vec::append_one(path, path_name(name)); - for vec::each(methods) |method| { + for vec::each_ref(methods) |method| { 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..a60985d9bdd 100644 --- a/src/rustc/middle/trans/monomorphize.rs +++ b/src/rustc/middle/trans/monomorphize.rs @@ -243,8 +243,8 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], let mut i = 0u; vec::map2(*bounds, substs, |bounds, subst| { let mut v = ~[]; - for vec::each(*bounds) |bound| { - match bound { + for vec::each_ref(*bounds) |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..c7739ad07b8 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -33,11 +33,11 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve::ExportMap, fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool { let mut found_export = false; - for vec::each(vis) |vi| { + for vec::each_ref(vis) |vi| { match vi.node { view_item_export(vps) => { found_export = true; - for vec::each(vps) |vp| { + for vec::each_ref(vps) |vp| { match vp.node { view_path_simple(_, _, _, id) | view_path_glob(_, id) | view_path_list(_, _, id) => { @@ -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_ref(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_ref(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_ref(nm.items) |item| { + cx.rmap.insert(item.id, ()); + } } } item_fn(_, _, tps, blk) => { @@ -103,7 +109,7 @@ fn traverse_public_item(cx: ctx, item: @item) { } } item_impl(tps, _, _, ms) => { - for vec::each(ms) |m| { + for vec::each_ref(ms) |m| { if tps.len() > 0u || m.tps.len() > 0u || attr::find_inline_attr(m.attrs) != attr::ia_none { cx.rmap.insert(m.id, ()); @@ -126,7 +132,7 @@ fn traverse_public_item(cx: ctx, item: @item) { traverse_inline_body(cx, dtor.node.body); } } - for vec::each(struct_def.methods) |m| { + for vec::each_ref(struct_def.methods) |m| { cx.rmap.insert(m.id, ()); if tps.len() > 0 || attr::find_inline_attr(m.attrs) != attr::ia_none { diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index b40afb6dd44..fe064c251d6 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -314,7 +314,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { ty::ty_rec(fields) => { let mut s = ~[shape_struct], sub = ~[]; - for vec::each(fields) |f| { + for vec::each_ref(fields) |f| { sub += shape_of(ccx, f.mt.ty); } add_substr(s, sub); @@ -322,8 +322,8 @@ 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); + for vec::each_ref(elts) |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_ref(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_ref(*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_ref(lv) |v| { add_u16(lv_table, *v as u16); } // Determine whether the enum has dynamic size. assert !vec::any(*variants, |v| { @@ -451,7 +451,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { inf += ~[size_align.align]; // Now write in the offset of each variant. - for vec::each(*variants) |_v| { + for vec::each_ref(*variants) |_v| { add_u16(inf, header_sz + inf_sz + offsets[i]); i += 1u; } @@ -478,17 +478,17 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { // variant that contains (T,T) must be as least as large as // any variant that contains just T. let mut ranges = ~[]; - for vec::each(*variants) |variant| { + for vec::each_ref(*variants) |variant| { 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) { + for vec::each_ref(variant.args) |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); } @@ -550,11 +550,11 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { -> size_align { let mut max_size = 0u16; let mut max_align = 1u8; - for vec::each(largest_variants) |vid| { + for vec::each_ref(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_ref(variants[*vid].args) |typ| { + lltys += ~[type_of::type_of(ccx, *typ)]; } let llty = trans::common::T_struct(lltys); @@ -724,7 +724,7 @@ fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { // Compute max(variant sizes). let mut max_size = 0u; let variants = ty::enum_variants(cx.tcx, tid); - for vec::each(*variants) |variant| { + for vec::each_ref(*variants) |variant| { let tup_ty = simplify_type(cx.tcx, ty::mk_tup(cx.tcx, variant.args)); // Perform any type parameter substitutions. diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index c0e695cbee1..ae202f6be88 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -334,8 +334,8 @@ fn write_content(bcx: block, add_clean_temp_mem(bcx, lleltptr, vt.unit_ty); vec::push(temp_cleanups, lleltptr); } - for vec::each(temp_cleanups) |cleanup| { - revoke_clean(bcx, cleanup); + for vec::each_ref(temp_cleanups) |cleanup| { + revoke_clean(bcx, *cleanup); } } } @@ -372,8 +372,8 @@ fn write_content(bcx: block, vec::push(temp_cleanups, lleltptr); } - for vec::each(temp_cleanups) |cleanup| { - revoke_clean(bcx, cleanup); + for vec::each_ref(temp_cleanups) |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..7feca7a2aa8 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -143,7 +143,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { ty::ty_rec(fields) => { let mut tys: ~[TypeRef] = ~[]; - for vec::each(fields) |f| { + for vec::each_ref(fields) |f| { let mt_ty = f.mt.ty; vec::push(tys, type_of(cx, mt_ty)); } @@ -157,8 +157,8 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { ty::ty_type => T_ptr(cx.tydesc_type), ty::ty_tup(elts) => { let mut tys = ~[]; - for vec::each(elts) |elt| { - vec::push(tys, type_of(cx, elt)); + for vec::each_ref(elts) |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..38015a9b50e 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -47,7 +47,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) let cx = {ccx: ccx, uses: vec::to_mut(vec::from_elem(n_tps, 0u))}; match ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).sty { ty::ty_fn(ref fn_ty) => { - for vec::each(fn_ty.sig.inputs) |arg| { + for vec::each_ref(fn_ty.sig.inputs) |arg| { if arg.mode == expl(by_val) { type_needs(cx, use_repr, arg.ty); } } } @@ -142,9 +142,9 @@ fn type_needs_inner(cx: ctx, use_: uint, ty: ty::t, ty::ty_enum(did, substs) => { if option::is_none(list::find(enums_seen, |id| *id == did)) { 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); + for vec::each_ref(*ty::enum_variants(cx.ccx.tcx, did)) |v| { + for vec::each_ref(v.args) |aty| { + let t = ty::subst(cx.ccx.tcx, &substs, *aty); type_needs_inner(cx, use_, t, seen); } } @@ -209,7 +209,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { ty::proto_bare | ty::proto_vstore(ty::vstore_uniq) => {} ty::proto_vstore(ty::vstore_box) | ty::proto_vstore(ty::vstore_slice(_)) => { - for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| { + for vec::each_ref(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| { let node_id = ast_util::def_id_of_def(fv.def).node; node_type_needs(cx, use_repr, node_id); } @@ -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_ref( + 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 7932474a698..bf4c6a96ba2 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -773,8 +773,8 @@ 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 { + for vec::each_ref(*bounds) |bound| { + match *bound { bound_copy => { kind = raise_kind(kind, kind_implicitly_copyable()); } @@ -1604,10 +1604,10 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool { ty_class(did, ref substs) => { // 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 + for vec::each_ref(ty::class_items_as_fields(cx, did, substs)) |f| { + if type_needs_drop(cx, f.mt.ty) { accum = true; } + } + accum } } ty_tup(elts) => { @@ -1616,7 +1616,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool { } ty_enum(did, ref substs) => { let variants = enum_variants(cx, did); - for vec::each(*variants) |variant| { + for vec::each_ref(*variants) |variant| { for variant.args.each |aty| { // Perform any type parameter substitutions. let arg_ty = subst(cx, substs, aty); @@ -1680,7 +1680,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, true } ty_enum(did, ref substs) => { - for vec::each(*enum_variants(cx, did)) |v| { + for vec::each_ref(*enum_variants(cx, did)) |v| { for v.args.each |aty| { let t = subst(cx, substs, aty); needs_unwind_cleanup |= @@ -2041,7 +2041,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { if vec::len(*variants) == 0u { lowest = kind_send_only() | kind_owned(); } else { - for vec::each(*variants) |variant| { + for vec::each_ref(*variants) |variant| { for variant.args.each |aty| { // Perform any type parameter substitutions. let arg_ty = subst(cx, substs, aty); @@ -2261,7 +2261,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(x: &sty) -> bool) -> if test(sty) { return true; } match *sty { ty_enum(did, ref substs) => { - for vec::each(*enum_variants(cx, did)) |variant| { + for vec::each_ref(*enum_variants(cx, did)) |variant| { for variant.args.each |aty| { let sty = subst(cx, substs, aty); if type_structurally_contains(cx, sty, test) { return true; } @@ -2350,7 +2350,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool { // Structural types ty_enum(did, ref substs) => { let variants = enum_variants(cx, did); - for vec::each(*variants) |variant| { + for vec::each_ref(*variants) |variant| { let tup_ty = mk_tup(cx, variant.args); // Perform any type parameter substitutions. @@ -2672,7 +2672,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_ref(subtys) |s| { h = (h << 2u) + type_id(*s) } h } pure fn hash_substs(h: uint, substs: &substs) -> uint { @@ -2713,12 +2713,12 @@ pure fn hash_type_structure(st: &sty) -> uint { ty_tup(ts) => hash_subtys(25u, ts), ty_rec(fields) => { let mut h = 26u; - for vec::each(fields) |f| { h = hash_subty(h, f.mt.ty); } + for vec::each_ref(fields) |f| { h = hash_subty(h, f.mt.ty); } h } ty_fn(ref f) => { let mut h = 27u; - for vec::each(f.sig.inputs) |a| { + for vec::each_ref(f.sig.inputs) |a| { h = hash_subty(h, a.ty); } hash_subty(h, f.sig.output) 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..278e811ae3b 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -292,8 +292,8 @@ impl LookupContext { let tcx = self.tcx(); 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 { + for vec::each_ref(*bounds) |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..b569980f893 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -48,8 +48,8 @@ fn lookup_vtables(fcx: @fn_ctxt, let tcx = fcx.ccx.tcx; let mut result = ~[], i = 0u; for substs.tps.each |ty| { - for vec::each(*bounds[i]) |bound| { - match bound { + for vec::each_ref(*bounds[i]) |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, @@ -121,8 +121,8 @@ fn lookup_vtable(fcx: @fn_ctxt, match ty::get(ty).sty { 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 { + for vec::each_ref(*tcx.ty_param_bounds.get(did.node)) |bound| { + match *bound { ty::bound_send | ty::bound_copy | ty::bound_const | ty::bound_owned => { /* ignore */ @@ -156,7 +156,7 @@ fn lookup_vtable(fcx: @fn_ctxt, relate_trait_tys(fcx, expr, trait_ty, ty); if !allow_unsafe && !is_early { - for vec::each(*ty::trait_methods(tcx, did)) |m| { + for vec::each_ref(*ty::trait_methods(tcx, did)) |m| { if ty::type_has_self(ty::mk_fn(tcx, m.fty)) { tcx.sess.span_err( expr.span, @@ -214,8 +214,8 @@ fn lookup_vtable(fcx: @fn_ctxt, // it's the same trait as trait_ty, we need to // 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 { + for vec::each_ref(ty::impl_traits(tcx, im.did)) |of_ty| { + 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..9b373438c04 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_ref(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..1b4953aa17b 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -358,12 +358,12 @@ fn check_methods_against_trait(ccx: @crate_ctxt, if did.crate == ast::local_crate { ensure_trait_methods(ccx, did.node, tpt.ty); } - for vec::each(*ty::trait_methods(tcx, did)) |trait_m| { + for vec::each_ref(*ty::trait_methods(tcx, did)) |trait_m| { match vec::find(impl_ms, |impl_m| trait_m.ident == impl_m.mty.ident) { 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 diff --git a/src/rustc/middle/typeck/infer/region_var_bindings.rs b/src/rustc/middle/typeck/infer/region_var_bindings.rs index 4f2eb7c7c75..5540b923197 100644 --- a/src/rustc/middle/typeck/infer/region_var_bindings.rs +++ b/src/rustc/middle/typeck/infer/region_var_bindings.rs @@ -1098,8 +1098,8 @@ impl RegionVarBindings { let upper_bounds = self.collect_concrete_regions(graph, node_idx, Outgoing); - for vec::each(lower_bounds) |lower_bound| { - for vec::each(upper_bounds) |upper_bound| { + for vec::each_ref(lower_bounds) |lower_bound| { + for vec::each_ref(upper_bounds) |upper_bound| { if !self.is_subregion_of(lower_bound.region, upper_bound.region) { @@ -1148,8 +1148,8 @@ impl RegionVarBindings { let upper_bounds = self.collect_concrete_regions(graph, node_idx, Outgoing); - for vec::each(upper_bounds) |upper_bound_1| { - for vec::each(upper_bounds) |upper_bound_2| { + for vec::each_ref(upper_bounds) |upper_bound_1| { + for vec::each_ref(upper_bounds) |upper_bound_2| { match self.glb_concrete_regions(upper_bound_1.region, upper_bound_2.region) { Ok(_) => {} |
