librustc: rename vec::each(var) to var.each

This commit is contained in:
Youngmin Yoo 2013-05-08 19:48:26 +09:00
parent 841f4ceaf4
commit c02064d153
19 changed files with 49 additions and 51 deletions

View File

@ -1084,7 +1084,7 @@ fn encode_index<T>(ebml_w: &mut writer::Encoder,
for buckets.each |bucket| {
bucket_locs.push(ebml_w.writer.tell());
ebml_w.start_tag(tag_index_buckets_bucket);
for vec::each(**bucket) |elt| {
for (**bucket).each |elt| {
ebml_w.start_tag(tag_index_buckets_bucket_elt);
assert!(elt.pos < 0xffff_ffff);
writer.write_be_u32(elt.pos as u32);

View File

@ -17,7 +17,6 @@ use core::hashmap::HashMap;
use core::io::WriterUtil;
use core::io;
use core::uint;
use core::vec;
use syntax::abi::AbiSet;
use syntax::ast;
use syntax::ast::*;
@ -398,7 +397,7 @@ fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
}
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
for vec::each(*bs) |bound| {
for (*bs).each |bound| {
match *bound {
ty::bound_owned => w.write_char('S'),
ty::bound_copy => w.write_char('C'),

View File

@ -366,7 +366,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
}
let variants = ty::enum_variants(cx.tcx, eid);
if found.len() != (*variants).len() {
for vec::each(*variants) |v| {
for (*variants).each |v| {
if !found.contains(&(variant(v.id))) {
return Some(variant(v.id));
}

View File

@ -235,7 +235,7 @@ fn check_fn(
}
fn check_arm(a: &arm, cx: Context, v: visit::vt<Context>) {
for vec::each(a.pats) |p| {
for a.pats.each |p| {
do pat_util::pat_bindings(cx.tcx.def_map, *p) |mode, id, span, _pth| {
if mode == bind_by_copy {
let t = ty::node_id_to_type(cx.tcx, id);

View File

@ -4630,7 +4630,7 @@ pub impl Resolver {
}
let mut smallest = 0;
for vec::eachi(maybes) |i, &other| {
for maybes.eachi |i, &other| {
values[i] = str::levdistance(name, other);
@ -4664,7 +4664,7 @@ pub impl Resolver {
if item.id == node_id {
match item.node {
item_struct(class_def, _) => {
for vec::each(class_def.fields) |field| {
for class_def.fields.each |field| {
match field.node.kind {
unnamed_field => {},
named_field(ident, _) => {

View File

@ -4681,7 +4681,7 @@ pub impl Resolver {
}
let mut smallest = 0;
for vec::eachi(maybes) |i, &other| {
for maybes.eachi |i, &other| {
values[i] = str::levdistance(name, other);
@ -4715,7 +4715,7 @@ pub impl Resolver {
if item.id == node_id {
match item.node {
item_struct(class_def, _) => {
for vec::each(class_def.fields) |field| {
for class_def.fields.each |field| {
match field.node.kind {
unnamed_field => {},
named_field(ident, _) => {

View File

@ -283,7 +283,7 @@ pub fn variant_opt(bcx: block, pat_id: ast::node_id)
match ccx.tcx.def_map.get_copy(&pat_id) {
ast::def_variant(enum_id, var_id) => {
let variants = ty::enum_variants(ccx.tcx, enum_id);
for vec::each(*variants) |v| {
for (*variants).each |v| {
if var_id == v.id {
return var(v.disr_val,
adt::represent_node(bcx, pat_id))
@ -349,7 +349,7 @@ pub fn matches_to_str(bcx: block, m: &[@Match]) -> ~str {
}
pub fn has_nested_bindings(m: &[@Match], col: uint) -> bool {
for vec::each(m) |br| {
for m.each |br| {
match br.pats[col].node {
ast::pat_ident(_, _, Some(_)) => return true,
_ => ()
@ -418,7 +418,7 @@ pub fn enter_match<'r>(bcx: block,
let _indenter = indenter();
let mut result = ~[];
for vec::each(m) |br| {
for m.each |br| {
match e(br.pats[col]) {
Some(sub) => {
let pats =
@ -934,7 +934,7 @@ pub fn collect_record_or_struct_fields(bcx: block,
col: uint)
-> ~[ast::ident] {
let mut fields: ~[ast::ident] = ~[];
for vec::each(m) |br| {
for m.each |br| {
match br.pats[col].node {
ast::pat_struct(_, ref fs, _) => {
match ty::get(node_id_type(bcx, br.pats[col].id)).sty {
@ -973,7 +973,7 @@ pub fn root_pats_as_necessary(mut bcx: block,
col: uint,
val: ValueRef)
-> block {
for vec::each(m) |br| {
for m.each |br| {
let pat_id = br.pats[col].id;
if pat_id != 0 {
let datum = Datum {val: val, ty: node_id_type(bcx, pat_id),
@ -1042,14 +1042,14 @@ pub fn pick_col(m: &[@Match]) -> uint {
}
}
let mut scores = vec::from_elem(m[0].pats.len(), 0u);
for vec::each(m) |br| {
for m.each |br| {
let mut i = 0u;
for vec::each(br.pats) |p| { scores[i] += score(*p); i += 1u; }
for br.pats.each |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 scores.each |score| {
let score = *score;
// Irrefutable columns always go first, they'd only be duplicated in
@ -1306,7 +1306,7 @@ pub fn compile_submatch(bcx: block,
let ccx = *bcx.fcx.ccx;
let mut pat_id = 0;
let mut pat_span = dummy_sp();
for vec::each(m) |br| {
for m.each |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 {
@ -1438,7 +1438,7 @@ pub fn compile_submatch(bcx: block,
}
}
}
for vec::each(opts) |o| {
for opts.each |o| {
match *o {
range(_, _) => { kind = compare; break }
_ => ()
@ -1460,7 +1460,7 @@ pub fn compile_submatch(bcx: block,
let mut i = 0u;
// Compile subtrees for each option
for vec::each(opts) |opt| {
for opts.each |opt| {
i += 1u;
let mut opt_cx = else_cx;
if !exhaustive || i < len {
@ -1631,7 +1631,7 @@ pub fn trans_match_inner(scope_cx: block,
}
let mut arm_datas = ~[], matches = ~[];
for vec::each(arms) |arm| {
for arms.each |arm| {
let body = scope_block(bcx, arm.body.info(), ~"case_body");
// Create the bindings map, which is a mapping from each binding name
@ -1670,7 +1670,7 @@ pub fn trans_match_inner(scope_cx: block,
arm: arm,
bindings_map: bindings_map};
arm_datas.push(arm_data);
for vec::each(arm.pats) |p| {
for arm.pats.each |p| {
matches.push(@Match {pats: ~[*p], data: arm_data});
}
}
@ -1793,7 +1793,7 @@ pub fn bind_irrefutable_pat(bcx: block,
vinfo.disr_val,
val);
for sub_pats.each |sub_pat| {
for vec::eachi(args.vals) |i, argval| {
for args.vals.eachi |i, argval| {
bcx = bind_irrefutable_pat(bcx,
sub_pat[i],
*argval,

View File

@ -668,7 +668,7 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
ty::ty_struct(*) => {
let repr = adt::represent_type(cx.ccx(), t);
do expr::with_field_tys(cx.tcx(), t, None) |discr, field_tys| {
for vec::eachi(field_tys) |i, field_ty| {
for field_tys.eachi |i, field_ty| {
let llfld_a = adt::trans_field_ptr(cx, repr, av, discr, i);
cx = f(cx, llfld_a, field_ty.mt.ty);
}
@ -709,7 +709,7 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
n_variants);
let next_cx = sub_block(cx, ~"enum-iter-next");
for vec::each(*variants) |variant| {
for (*variants).each |variant| {
let variant_cx =
sub_block(cx, ~"enum-iter-variant-" +
int::to_str(variant.disr_val));
@ -888,7 +888,7 @@ pub fn need_invoke(bcx: block) -> bool {
match cur.kind {
block_scope(inf) => {
let inf = &mut *inf; // FIXME(#5074) workaround old borrowck
for vec::each(inf.cleanups) |cleanup| {
for inf.cleanups.each |cleanup| {
match *cleanup {
clean(_, cleanup_type) | clean_temp(_, _, cleanup_type) => {
if cleanup_type == normal_exit_and_unwind {
@ -1391,7 +1391,7 @@ pub fn with_scope_datumblock(bcx: block, opt_node_info: Option<NodeInfo>,
}
pub fn block_locals(b: &ast::blk, it: &fn(@ast::local)) {
for vec::each(b.node.stmts) |s| {
for b.node.stmts.each |s| {
match s.node {
ast::stmt_decl(d, _) => {
match d.node {
@ -1973,7 +1973,7 @@ pub fn trans_enum_variant(ccx: @CrateContext,
repr, ty_to_str(ccx.tcx, enum_ty));
adt::trans_start_init(bcx, repr, fcx.llretptr.get(), disr);
for vec::eachi(args) |i, va| {
for args.eachi |i, va| {
let lldestptr = adt::trans_field_ptr(bcx,
repr,
fcx.llretptr.get(),
@ -2072,7 +2072,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::enum_def,
id: ast::node_id, vi: @~[ty::VariantInfo],
i: &mut uint) {
for vec::each(enum_definition.variants) |variant| {
for enum_definition.variants.each |variant| {
let disr_val = vi[*i].disr_val;
*i += 1;
@ -2559,7 +2559,7 @@ pub fn trans_constant(ccx: @CrateContext, it: @ast::item) {
node: it.id });
let mut i = 0;
let path = item_path(ccx, it);
for vec::each((*enum_definition).variants) |variant| {
for (*enum_definition).variants.each |variant| {
let p = vec::append(/*bad*/copy path, ~[
path_name(variant.node.name),
path_name(special_idents::descrim)

View File

@ -161,7 +161,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
cls: &mut [x86_64_reg_class], i: uint,
off: uint) {
let mut field_off = off;
for vec::each(tys) |ty| {
for tys.each |ty| {
field_off = align(field_off, *ty);
classify(*ty, cls, i, field_off);
field_off += ty_size(*ty);
@ -283,7 +283,7 @@ 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| {
for cls.each |c| {
if *c != sseup_class {
break;
}
@ -370,7 +370,7 @@ fn x86_64_tys(atys: &[TypeRef],
let mut arg_tys = ~[];
let mut attrs = ~[];
for vec::each(atys) |t| {
for atys.each |t| {
let (ty, attr) = x86_64_ty(*t, is_pass_byval, ByValAttribute);
arg_tys.push(ty);
attrs.push(attr);

View File

@ -631,7 +631,7 @@ pub fn trans_args(cx: block,
match args {
ArgExprs(arg_exprs) => {
let last = arg_exprs.len() - 1u;
for vec::eachi(arg_exprs) |i, arg_expr| {
for arg_exprs.eachi |i, arg_expr| {
let arg_val = unpack_result!(bcx, {
trans_arg_expr(bcx,
arg_tys[i],

View File

@ -34,7 +34,7 @@ pub 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 b.node.stmts.each |s| {
debuginfo::update_source_pos(bcx, b.span);
bcx = trans_stmt(bcx, *s);
}
@ -107,7 +107,7 @@ pub fn trans_if(bcx: block,
pub 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 in_cxs.each |bcx| {
if !bcx.unreachable {
Br(*bcx, out.llbb);
reachable = true;

View File

@ -1264,7 +1264,7 @@ fn trans_adt(bcx: block, repr: &adt::Repr, discr: int,
}
}
for vec::each(temp_cleanups) |cleanup| {
for temp_cleanups.each |cleanup| {
revoke_clean(bcx, *cleanup);
}
return bcx;

View File

@ -294,7 +294,7 @@ pub fn trans_foreign_mod(ccx: @CrateContext,
Some(abi) => abi,
};
for vec::each(foreign_mod.items) |&foreign_item| {
for foreign_mod.items.each |&foreign_item| {
match foreign_item.node {
ast::foreign_item_fn(*) => {
let id = foreign_item.id;

View File

@ -51,7 +51,7 @@ pub fn trans_impl(ccx: @CrateContext, path: path, name: ast::ident,
if !generics.ty_params.is_empty() { return; }
let sub_path = vec::append_one(path, path_name(name));
for vec::each(methods) |method| {
for methods.each |method| {
if method.generics.ty_params.len() == 0u {
let llfn = get_item_val(ccx, method.id);
let path = vec::append_one(/*bad*/copy sub_path,

View File

@ -28,7 +28,6 @@ use util::common::indenter;
use util::ppaux::ty_to_str;
use core::option::None;
use core::vec;
use syntax::ast;
use syntax::codemap;
@ -395,7 +394,7 @@ pub fn write_content(bcx: block,
add_clean_temp_mem(bcx, lleltptr, vt.unit_ty);
temp_cleanups.push(lleltptr);
}
for vec::each(temp_cleanups) |cleanup| {
for temp_cleanups.each |cleanup| {
revoke_clean(bcx, *cleanup);
}
}

View File

@ -77,7 +77,7 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
match ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).sty {
ty::ty_bare_fn(ty::BareFnTy {sig: ref sig, _}) |
ty::ty_closure(ty::ClosureTy {sig: ref sig, _}) => {
for vec::each(sig.inputs) |arg| {
for sig.inputs.each |arg| {
type_needs(cx, use_repr, arg.ty);
}
}
@ -213,7 +213,7 @@ pub fn type_needs_inner(cx: Context,
if list::find(enums_seen, |id| *id == did).is_none() {
let seen = @Cons(did, enums_seen);
for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) |v| {
for vec::each(v.args) |aty| {
for v.args.each |aty| {
let t = ty::subst(cx.ccx.tcx, &(*substs), *aty);
type_needs_inner(cx, use_, t, seen);
}

View File

@ -1740,7 +1740,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 (*enum_variants(cx, did)).each |v| {
for v.args.each |aty| {
let t = subst(cx, substs, *aty);
needs_unwind_cleanup |=
@ -2335,7 +2335,7 @@ pub fn type_structurally_contains(cx: ctxt,
if test(sty) { return true; }
match *sty {
ty_enum(did, ref substs) => {
for vec::each(*enum_variants(cx, did)) |variant| {
for (*enum_variants(cx, did)).each |variant| {
for variant.args.each |aty| {
let sty = subst(cx, substs, *aty);
if type_structurally_contains(cx, sty, test) { return true; }
@ -2431,7 +2431,7 @@ pub 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 (*variants).each |variant| {
let tup_ty = mk_tup(cx, /*bad*/copy variant.args);
// Perform any type parameter substitutions.

View File

@ -228,7 +228,7 @@ fn visit_expr(e: @ast::expr, wbcx: @mut WbCtxt, v: wb_vt) {
match e.node {
ast::expr_fn_block(ref decl, _) => {
for vec::each(decl.inputs) |input| {
for decl.inputs.each |input| {
let _ = resolve_type_vars_for_node(wbcx, e.span, input.id);
}
}

View File

@ -1572,8 +1572,8 @@ pub impl RegionVarBindings {
return;
}
for vec::each(lower_bounds) |lower_bound| {
for vec::each(upper_bounds) |upper_bound| {
for lower_bounds.each |lower_bound| {
for upper_bounds.each |upper_bound| {
if !self.is_subregion_of(lower_bound.region,
upper_bound.region) {
@ -1629,8 +1629,8 @@ pub impl RegionVarBindings {
return;
}
for vec::each(upper_bounds) |upper_bound_1| {
for vec::each(upper_bounds) |upper_bound_2| {
for upper_bounds.each |upper_bound_1| {
for upper_bounds.each |upper_bound_2| {
match self.glb_concrete_regions(upper_bound_1.region,
upper_bound_2.region) {
Ok(_) => {}