reorder args to the various vec, option fns so blk comes last

This commit is contained in:
Niko Matsakis 2011-12-16 06:27:50 -08:00
parent 0a3626161d
commit 2833ca478c
37 changed files with 170 additions and 169 deletions

View file

@ -325,7 +325,7 @@ fn check_alt(cx: ctx, input: @ast::expr, arms: [ast::arm], sc: scope,
for pat in a.pats {
for proot in pattern_roots(cx.tcx, root.mut, pat) {
let canon_id = pat_id_map.get(proot.name);
alt vec::find({|x| x.id == canon_id}, binding_info) {
alt vec::find(binding_info, {|x| x.id == canon_id}) {
some(s) { s.unsafe_tys += unsafe_set(proot.mut); }
none. {
binding_info += [
@ -683,7 +683,7 @@ fn filter_invalid(src: list<@invalid>, bs: [binding]) -> list<@invalid> {
while cur != list::nil {
alt cur {
list::cons(head, tail) {
let p = vec::position_pred({|b| b.node_id == head.node_id}, bs);
let p = vec::position_pred(bs, {|b| b.node_id == head.node_id});
if !is_none(p) { out = list::cons(head, @out); }
cur = *tail;
}

View file

@ -78,7 +78,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
let t = ty::expr_ty(cx.tcx, ex);
let ty_fields = alt ty::struct(cx.tcx, t) { ty::ty_rec(f) { f } };
for tf in ty_fields {
if !vec::any({|f| f.node.ident == tf.ident}, fields) &&
if !vec::any(fields, {|f| f.node.ident == tf.ident}) &&
!kind_can_be_copied(ty::type_kind(cx.tcx, tf.mt.ty)) {
cx.tcx.sess.span_err(ex.span,
"copying a noncopyable value");

View file

@ -197,7 +197,7 @@ fn join_branches(branches: [set]) -> set {
for set in branches {
i += 1u;
for {def, exprs} in set {
if !vec::any({|v| v.def == def}, found) {
if !vec::any(found, {|v| v.def == def}) {
let j = i, ne = exprs;
while j < l {
for {def: d2, exprs} in branches[j] {
@ -234,8 +234,8 @@ fn clear_in_current(cx: ctx, my_def: node_id, to: bool) {
cx.last_uses.insert(expr, to);
}
}
cx.current = vec::filter({|x| x.def != my_def},
copy cx.current);
cx.current = vec::filter(copy cx.current,
{|x| x.def != my_def});
break;
}
}

View file

@ -1152,8 +1152,8 @@ fn lookup_in_globs(e: env, globs: [glob_imp_def], sp: span, id: ident,
none. { none }
}
}
let matches = vec::filter_map(bind lookup_in_mod_(e, _, sp, id, ns, dr),
copy globs);
let matches = vec::filter_map(copy globs,
bind lookup_in_mod_(e, _, sp, id, ns, dr));
if vec::len(matches) == 0u {
ret none;
} else if vec::len(matches) == 1u {
@ -1448,7 +1448,7 @@ fn check_arm(e: @env, a: ast::arm, &&x: (), v: vt<()>) {
"inconsistent number of bindings");
} else {
for name: ident in ch.seen {
if is_none(vec::find(bind str::eq(name, _), seen0)) {
if is_none(vec::find(seen0, bind str::eq(name, _))) {
// Fight the alias checker
let name_ = name;
e.sess.span_err(a.pats[i].span,

View file

@ -3428,9 +3428,9 @@ fn trans_rec(bcx: @block_ctxt, fields: [ast::field],
let ty_fields = alt ty::struct(bcx_tcx(bcx), t) { ty::ty_rec(f) { f } };
let temp_cleanups = [];
for fld in fields {
let ix = option::get(vec::position_pred({|ft|
let ix = option::get(vec::position_pred(ty_fields, {|ft|
str::eq(fld.node.ident, ft.ident)
}, ty_fields));
}));
let dst = GEP_tup_like_1(bcx, t, addr, [0, ix as int]);
bcx = trans_expr_save_in(dst.bcx, fld.node.expr, dst.val);
add_clean_temp_mem(bcx, dst.val, ty_fields[ix].mt.ty);
@ -3442,7 +3442,7 @@ fn trans_rec(bcx: @block_ctxt, fields: [ast::field],
bcx = cx;
// Copy over inherited fields
for tf in ty_fields {
if !vec::any({|f| str::eq(f.node.ident, tf.ident)}, fields) {
if !vec::any(fields, {|f| str::eq(f.node.ident, tf.ident)}) {
let dst = GEP_tup_like_1(bcx, t, addr, [0, i]);
let base = GEP_tup_like_1(bcx, t, base_val, [0, i]);
let val = load_if_immediate(base.bcx, base.val, tf.mt.ty);

View file

@ -291,7 +291,7 @@ fn collect_record_fields(m: match, col: uint) -> [ast::ident] {
alt br.pats[col].node {
ast::pat_rec(fs, _) {
for f: ast::field_pat in fs {
if !vec::any(bind str::eq(f.ident, _), fields) {
if !vec::any(fields, bind str::eq(f.ident, _)) {
fields += [f.ident];
}
}

View file

@ -426,7 +426,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t,
// Actually construct the closure
let {llbox, box_ty, bcx} = store_environment(
bcx, lltydescs,
env_vals + vec::map({|x| env_expr(x)}, bound),
env_vals + vec::map(bound, {|x| env_expr(x)}),
ty::closure_shared);
// Make thunk

View file

@ -244,8 +244,8 @@ fn trans_anon_obj(bcx: @block_ctxt, sp: span, anon_obj: ast::anon_obj,
// methods, not inner ones.
let wrapper_obj: ast::_obj =
{fields:
vec::map(ast_util::obj_field_from_anon_obj_field,
additional_fields),
vec::map(additional_fields,
ast_util::obj_field_from_anon_obj_field),
methods: anon_obj.methods};
let inner_obj_ty: ty::t;
@ -481,7 +481,7 @@ fn create_vtbl(cx: @local_ctxt, sp: span, outer_obj_ty: ty::t, ob: ast::_obj,
// Filter out any methods that we don't need forwarding slots for
// because they're being overridden.
let f = bind filtering_fn(cx, _, ob.methods);
meths = vec::filter_map(f, meths);
meths = vec::filter_map(meths, f);
// And now add the additional ones, both overriding ones and entirely
// new ones. These will just be normal methods.

View file

@ -1083,7 +1083,7 @@ fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> [init_op] {
fn mode_to_op(m: ty::mode) -> init_op {
alt m { by_move. { init_move } _ { init_assign } }
}
vec::map(mode_to_op, callee_modes(fcx, callee))
vec::map(callee_modes(fcx, callee), mode_to_op)
}
fn anon_bindings(ops: [init_op], es: [@expr]) -> [binding] {

View file

@ -95,10 +95,10 @@ fn find_pre_post_exprs(fcx: fn_ctxt, args: [@expr], id: node_id) {
fn get_pp(ccx: crate_ctxt, &&e: @expr) -> pre_and_post {
ret expr_pp(ccx, e);
}
let pps = vec::map(bind get_pp(fcx.ccx, _), args);
let pps = vec::map(args, bind get_pp(fcx.ccx, _));
set_pre_and_post(fcx.ccx, id, seq_preconds(fcx, pps),
seq_postconds(fcx, vec::map(get_post, pps)));
seq_postconds(fcx, vec::map(pps, get_post)));
}
fn find_pre_post_loop(fcx: fn_ctxt, l: @local, index: @expr, body: blk,
@ -472,7 +472,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
postcondition: false_postcond(num_local_vars)};
let g = bind combine_pp(antec_pp, fcx, _, _);
let alts_overall_pp =
vec::foldl::<pre_and_post, pre_and_post>(g, e_pp, alt_pps);
vec::foldl(e_pp, alt_pps, g);
set_pre_and_post(fcx.ccx, e.id, alts_overall_pp.precondition,
alts_overall_pp.postcondition);
}
@ -669,7 +669,7 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) {
for s: @stmt in b.node.stmts { do_one_(fcx, s); }
fn do_inner_(fcx: fn_ctxt, &&e: @expr) { find_pre_post_expr(fcx, e); }
let do_inner = bind do_inner_(fcx, _);
option::map::<@expr, ()>(do_inner, b.node.expr);
option::map::<@expr, ()>(b.node.expr, do_inner);
let pps: [pre_and_post] = [];
for s: @stmt in b.node.stmts { pps += [stmt_pp(fcx.ccx, *s)]; }

View file

@ -1708,7 +1708,7 @@ fn field_idx(sess: session::session, sp: span, id: ast::ident,
fn get_field(tcx: ctxt, rec_ty: t, id: ast::ident) -> field {
alt struct(tcx, rec_ty) {
ty_rec(fields) {
alt vec::find({|f| str::eq(f.ident, id) }, fields) {
alt vec::find(fields, {|f| str::eq(f.ident, id) }) {
some(f) { ret f; }
}
}

View file

@ -323,7 +323,7 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
typ = ty::mk_ptr(tcx, ast_mt_to_mt(tcx, mode, mt));
}
ast::ty_tup(fields) {
let flds = vec::map(bind ast_ty_to_ty(tcx, mode, _), fields);
let flds = vec::map(fields, bind ast_ty_to_ty(tcx, mode, _));
typ = ty::mk_tup(tcx, flds);
}
ast::ty_rec(fields) {
@ -516,8 +516,8 @@ fn ty_of_native_fn_decl(tcx: ty::ctxt, mode: mode, decl: ast::fn_decl,
ret tpt;
}
fn ty_of_method(tcx: ty::ctxt, mode: mode, m: @ast::method) -> ty::method {
let inputs = vec::map({|i| ty_of_arg(tcx, mode, i)},
m.node.meth.decl.inputs);
let inputs = vec::map(m.node.meth.decl.inputs,
{|i| ty_of_arg(tcx, mode, i)});
let output = ast_ty_to_ty(tcx, mode, m.node.meth.decl.output);
let out_constrs = [];
@ -540,7 +540,7 @@ fn ty_of_obj(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj,
}
fn ty_of_obj_methods(tcx: ty::ctxt, mode: mode, object: ast::_obj)
-> [ty::method] {
vec::map({|m| ty_of_method(tcx, mode, m)}, object.methods)
vec::map(object.methods, {|m| ty_of_method(tcx, mode, m)})
}
fn ty_of_obj_ctor(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj,
ctor_id: ast::node_id, ty_params: [ast::ty_param])
@ -1331,7 +1331,7 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
ret str::eq(name, f.ident);
}
for f: ast::field_pat in fields {
alt vec::find(bind matches(f.ident, _), ex_fields) {
alt vec::find(ex_fields, bind matches(f.ident, _)) {
some(field) { check_pat(fcx, map, f.pat, field.mt.ty); }
none. {
fcx.ccx.tcx.sess.span_fatal(pat.span,
@ -2091,7 +2091,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
alt base {
none. {
fn get_node(f: spanned<field>) -> field { f.node }
let typ = ty::mk_rec(tcx, vec::map(get_node, fields_t));
let typ = ty::mk_rec(tcx, vec::map(fields_t, get_node));
write::ty_only_fixup(fcx, id, typ);
}
some(bexpr) {
@ -2140,7 +2140,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
ids += b.ids;
fty = b.ty;
}
let substs = vec::map({|id| ty::mk_var(tcx, id)}, ids);
let substs = vec::map(ids, {|id| ty::mk_var(tcx, id)});
write::ty_fixup(fcx, id, {substs: some(substs), ty: fty});
fcx.ccx.method_map.insert(id, local_def(method.node.id));
}
@ -2268,7 +2268,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
}
let f = bind filtering_fn(fcx.ccx, _, ao.methods);
inner_obj_methods = vec::filter_map(f, inner_obj_methods);
inner_obj_methods = vec::filter_map(inner_obj_methods, f);
method_types += inner_obj_methods;
}
@ -2287,8 +2287,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
}
fcx.ccx.self_infos +=
[self_obj(vec::map(ast_util::obj_field_from_anon_obj_field,
fields), ot)];
[self_obj(
vec::map(fields, ast_util::obj_field_from_anon_obj_field),
ot)];
// Typecheck the methods.
for method: @ast::method in ao.methods {
check_method(fcx.ccx, method);