Skip to content

Commit

Permalink
librustc: rename vec::each(var) to var.each
Browse files Browse the repository at this point in the history
  • Loading branch information
recrack committed May 9, 2013
1 parent 841f4ce commit c02064d
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/librustc/metadata/encoder.rs
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/metadata/tyencode.rs
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_match.rs
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/kind.rs
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/resolve.rs
Expand Up @@ -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);

Expand Down Expand Up @@ -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, _) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/resolve_stage0.rs
Expand Up @@ -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);

Expand Down Expand Up @@ -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, _) => {
Expand Down
28 changes: 14 additions & 14 deletions src/librustc/middle/trans/_match.rs
Expand Up @@ -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))
Expand Down Expand Up @@ -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,
_ => ()
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 }
_ => ()
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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});
}
}
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/middle/trans/base.rs
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/cabi_x86_64.rs
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/callee.rs
Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/controlflow.rs
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/expr.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/foreign.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/meth.rs
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/tvec.rs
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/type_use.rs
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
Expand Down

5 comments on commit c02064d

@bors
Copy link
Contributor

@bors bors commented on c02064d May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from sanxiyn
at recrack@c02064d

@bors
Copy link
Contributor

@bors bors commented on c02064d May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging recrack/rust/rename_cleanup = c02064d into auto

@bors
Copy link
Contributor

@bors bors commented on c02064d May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recrack/rust/rename_cleanup = c02064d merged ok, testing candidate = 936c07d

@bors
Copy link
Contributor

@bors bors commented on c02064d May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on c02064d May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 936c07d

Please sign in to comment.