diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-09-21 18:43:30 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-09-21 19:13:55 -0700 |
| commit | 3d59ac3a1989c2d233b04cc8adc9b058690c2544 (patch) | |
| tree | c23ae510c35a35277d2807f9761aa7135356243b /src/rustc | |
| parent | f3c31a07d742478babfc7cda9d21ea6173ac2f6d (diff) | |
| download | rust-3d59ac3a1989c2d233b04cc8adc9b058690c2544.tar.gz rust-3d59ac3a1989c2d233b04cc8adc9b058690c2544.zip | |
De-mode vec::map, vec::eachi, vec::rev_each, vec::rev_eachi
Diffstat (limited to 'src/rustc')
34 files changed, 107 insertions, 112 deletions
diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index 207a8f3fc94..132bbc96344 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -93,7 +93,7 @@ fn get_rpaths_relative_to_output(os: session::os, output: &Path, libs: &[Path]) -> ~[Path] { vec::map(libs, |a| { - get_rpath_relative_to_output(os, output, &a) + get_rpath_relative_to_output(os, output, a) }) } @@ -148,7 +148,7 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path { } fn get_absolute_rpaths(libs: &[Path]) -> ~[Path] { - vec::map(libs, |a| get_absolute_rpath(&a) ) + vec::map(libs, |a| get_absolute_rpath(a) ) } fn get_absolute_rpath(lib: &Path) -> Path { diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index f08a067d0ef..d0f281f8128 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -553,7 +553,7 @@ fn build_session_options(binary: ~str, let addl_lib_search_paths = getopts::opt_strs(matches, ~"L") - .map(|s| Path(s)); + .map(|s| Path(*s)); let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~"cfg")); let test = opt_present(matches, ~"test"); let sopts: @session::options = diff --git a/src/rustc/front/config.rs b/src/rustc/front/config.rs index 7599d94e0f6..792d944169a 100644 --- a/src/rustc/front/config.rs +++ b/src/rustc/front/config.rs @@ -55,7 +55,7 @@ fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) -> let view_item_filter = |a| filter_view_item(cx, a); let filtered_view_items = vec::filter_map(m.view_items, view_item_filter); return { - view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)), + view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)), items: vec::filter_map(filtered_items, |x| fld.fold_item(x)) }; } @@ -76,7 +76,7 @@ fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod, nm.view_items, view_item_filter); return { sort: nm.sort, - view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)), + view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)), items: filtered_items }; } @@ -103,7 +103,7 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) -> let filter = |a| filter_stmt(cx, a); let filtered_stmts = vec::filter_map(b.stmts, filter); return {view_items: b.view_items, - stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(x)), + stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)), expr: option::map(b.expr, |x| fld.fold_expr(x)), id: b.id, rules: b.rules}; diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index 03e15487ab9..f6c2bf7d5a1 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -63,9 +63,9 @@ fn warn_if_multiple_versions(e: env, diag: span_handler, partition(crate_cache.map_to_vec(|entry| { let othername = loader::crate_name_from_metas(*entry.metas); if name == othername { - Left(entry) + Left(*entry) } else { - Right(entry) + Right(*entry) } })); diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index cec533a2d0c..dd90168d5c0 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -171,7 +171,7 @@ fn get_dep_hashes(cstore: cstore) -> ~[~str] { for sorted.each |x| { debug!(" hash[%s]: %s", x.name, x.hash); } - fn mapper(ch: crate_hash) -> ~str { return ch.hash; } + fn mapper(ch: &crate_hash) -> ~str { return ch.hash; } return vec::map(sorted, mapper); } diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index d817993f771..51c6b6148ce 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -283,9 +283,7 @@ fn item_path(intr: ident_interner, item_doc: ebml::Doc) -> ast_map::path { let len_doc = ebml::get_doc(path_doc, tag_path_len); let len = ebml::doc_as_u32(len_doc) as uint; - let mut result = ~[]; - vec::reserve(result, len); - + let mut result = vec::with_capacity(len); for ebml::docs(path_doc) |tag, elt_doc| { if tag == tag_path_elt_mod { let str = ebml::doc_as_str(elt_doc); diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 67c85102cd6..91d7c723694 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -1026,7 +1026,7 @@ fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml::Writer, type numdep = decoder::crate_dep; // Pull the cnums and name,vers,hash out of cstore - let mut deps: ~[mut numdep] = ~[mut]; + let mut deps: ~[numdep] = ~[]; do cstore::iter_crate_data(cstore) |key, val| { let dep = {cnum: key, name: ecx.tcx.sess.ident_of(val.name), vers: decoder::get_crate_vers(val.data), diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index a8551319da2..e01790641f0 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -81,7 +81,7 @@ fn raw_pat(p: @pat) -> @pat { fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) { assert(pats.is_not_empty()); - let ext = match is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) { + let ext = match is_useful(tcx, vec::map(pats, |p| ~[*p]), ~[wild()]) { not_useful => return, // This is good, wildcard pattern isn't reachable useful_ => None, useful(ty, ctor) => { diff --git a/src/rustc/middle/const_eval.rs b/src/rustc/middle/const_eval.rs index 86b7bd8ab8d..e26b3e55eed 100644 --- a/src/rustc/middle/const_eval.rs +++ b/src/rustc/middle/const_eval.rs @@ -83,7 +83,7 @@ fn classify(e: @expr, ast::expr_tup(es) | ast::expr_vec(es, ast::m_imm) => { - join_all(vec::map(es, |e| classify(e, def_map, tcx))) + join_all(vec::map(es, |e| classify(*e, def_map, tcx))) } ast::expr_vstore(e, vstore) => { diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 7158754429b..db39c616b55 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -1287,7 +1287,7 @@ impl Resolver { for full_path.idents.eachi |i, ident| { if i != path_len - 1u { - (*module_path).push(ident); + (*module_path).push(*ident); } } } @@ -3762,8 +3762,8 @@ impl Resolver { fn check_consistent_bindings(arm: arm) { if arm.pats.len() == 0 { return; } let map_0 = self.binding_mode_map(arm.pats[0]); - for arm.pats.eachi() |i, p: @pat| { - let map_i = self.binding_mode_map(p); + for arm.pats.eachi() |i, p| { + let map_i = self.binding_mode_map(*p); for map_0.each |key, binding_0| { match map_i.find(key) { @@ -3894,7 +3894,7 @@ impl Resolver { debug!("(resolving type) writing resolution for `%s` \ (id %d)", connect(path.idents.map( - |x| self.session.str_of(x)), ~"::"), + |x| self.session.str_of(*x)), ~"::"), path_id); self.record_def(path_id, def); } @@ -3902,7 +3902,7 @@ impl Resolver { self.session.span_err (ty.span, fmt!("use of undeclared type name `%s`", connect(path.idents.map( - |x| self.session.str_of(x)), + |x| self.session.str_of(*x)), ~"::"))); } } @@ -4080,7 +4080,7 @@ impl Resolver { path.span, fmt!("`%s` does not name a structure", connect(path.idents.map( - |x| self.session.str_of(x)), + |x| self.session.str_of(*x)), ~"::"))); } } @@ -4256,7 +4256,7 @@ impl Resolver { break; } - (*module_path_atoms).push(ident); + (*module_path_atoms).push(*ident); } return module_path_atoms; @@ -4482,13 +4482,13 @@ impl Resolver { // Write the result into the def map. debug!("(resolving expr) resolved `%s`", connect(path.idents.map( - |x| self.session.str_of(x)), ~"::")); + |x| self.session.str_of(*x)), ~"::")); self.record_def(expr.id, def); } None => { let wrong_name = connect(path.idents.map( - |x| self.session.str_of(x)), ~"::") ; + |x| self.session.str_of(*x)), ~"::") ; if self.name_exists_in_scope_class(wrong_name) { self.session.span_err(expr.span, fmt!("unresolved name: `%s`. \ @@ -4550,7 +4550,7 @@ impl Resolver { path.span, fmt!("`%s` does not name a structure", connect(path.idents.map( - |x| self.session.str_of(x)), + |x| self.session.str_of(*x)), ~"::"))); } } diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 376e70fc6c5..c7abed19c59 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -210,14 +210,14 @@ struct Match { fn match_to_str(bcx: block, m: &Match) -> ~str { if bcx.sess().verbose() { // for many programs, this just take too long to serialize - fmt!("%?", m.pats.map(|p| pat_to_str(p, bcx.sess().intr()))) + fmt!("%?", m.pats.map(|p| pat_to_str(*p, bcx.sess().intr()))) } else { fmt!("%u pats", m.pats.len()) } } fn matches_to_str(bcx: block, m: &[@Match]) -> ~str { - fmt!("%?", m.map(|n| match_to_str(bcx, n))) + fmt!("%?", m.map(|n| match_to_str(bcx, *n))) } fn has_nested_bindings(m: &[@Match], col: uint) -> bool { @@ -256,7 +256,7 @@ fn expand_nested_bindings(bcx: block, m: &[@Match/&r], @Match {pats: pats, data: br.data} } _ => { - br + *br } } } @@ -789,7 +789,7 @@ fn compile_guard(bcx: block, bcx.to_str(), bcx.expr_to_str(guard_expr), matches_to_str(bcx, m), - vals.map(|v| bcx.val_str(v))); + vals.map(|v| bcx.val_str(*v))); let _indenter = indenter(); let mut bcx = bcx; @@ -840,7 +840,7 @@ fn compile_submatch(bcx: block, debug!("compile_submatch(bcx=%s, m=%s, vals=%?)", bcx.to_str(), matches_to_str(bcx, m), - vals.map(|v| bcx.val_str(v))); + vals.map(|v| bcx.val_str(*v))); let _indenter = indenter(); /* @@ -895,7 +895,7 @@ fn compile_submatch(bcx: block, let pat_ty = node_id_type(bcx, pat_id); do expr::with_field_tys(tcx, pat_ty) |_has_dtor, field_tys| { let rec_vals = rec_fields.map(|field_name| { - let ix = ty::field_idx_strict(tcx, field_name, field_tys); + let ix = ty::field_idx_strict(tcx, *field_name, field_tys); GEPi(bcx, val, struct_field(ix)) }); compile_submatch( @@ -1227,7 +1227,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, for sub_pats.each |sub_pat| { for vec::eachi(args.vals) |i, argval| { bcx = bind_irrefutable_pat(bcx, sub_pat[i], - argval, make_copy); + *argval, make_copy); } } } @@ -1245,7 +1245,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, ast::pat_tup(elems) => { for vec::eachi(elems) |i, elem| { let fldptr = GEPi(bcx, val, [0u, i]); - bcx = bind_irrefutable_pat(bcx, elem, fldptr, make_copy); + bcx = bind_irrefutable_pat(bcx, *elem, fldptr, make_copy); } } ast::pat_box(inner) | ast::pat_uniq(inner) | diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index aaed7d35343..469e86da04e 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -206,7 +206,7 @@ fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id, assert ix < variant.args.len(); let arg_lltys = vec::map(variant.args, |aty| { - type_of(ccx, ty::subst_tps(ccx.tcx, ty_substs, aty)) + type_of(ccx, ty::subst_tps(ccx.tcx, ty_substs, *aty)) }); let typed_blobptr = PointerCast(bcx, llblobptr, T_ptr(T_struct(arg_lltys))); @@ -560,7 +560,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, ty::ty_tup(args) => { for vec::eachi(args) |i, arg| { let llfld_a = GEPi(cx, av, [0u, i]); - cx = f(cx, llfld_a, arg); + cx = f(cx, llfld_a, *arg); } } ty::ty_enum(tid, substs) => { @@ -1113,17 +1113,17 @@ 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; - for vec::reach(cleanups) |cu| { - match cu { - clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) => { + for vec::rev_each(cleanups) |cu| { + match *cu { + clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) => { // Some types don't need to be cleaned up during // landing pads because they can be freed en mass later if cleanup_type == normal_exit_and_unwind || !is_lpad { bcx = cfn(bcx); } - } } } + } return bcx; } diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index c0846a601bd..865374054e6 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -144,7 +144,7 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], cx.terminated = true; debug!("Invoke(%s with arguments (%s))", val_str(cx.ccx().tn, Fn), - str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, a)), + str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, *a)), ~", ")); unsafe { count_insn(cx, "invoke"); @@ -677,7 +677,7 @@ fn Call(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef { debug!("Call(Fn=%s, Args=%?)", val_str(cx.ccx().tn, Fn), - Args.map(|arg| val_str(cx.ccx().tn, arg))); + Args.map(|arg| val_str(cx.ccx().tn, *arg))); do vec::as_imm_buf(Args) |ptr, len| { llvm::LLVMBuildCall(B(cx), Fn, ptr, len as c_uint, noname()) diff --git a/src/rustc/middle/trans/callee.rs b/src/rustc/middle/trans/callee.rs index 946a55318eb..f79fd8c97e7 100644 --- a/src/rustc/middle/trans/callee.rs +++ b/src/rustc/middle/trans/callee.rs @@ -174,7 +174,7 @@ fn trans_fn_ref_with_vtables( debug!("trans_fn_ref_with_vtables(bcx=%s, def_id=%?, ref_id=%?, \ type_params=%?, vtables=%?)", bcx.to_str(), def_id, ref_id, - type_params.map(|t| bcx.ty_to_str(t)), + type_params.map(|t| bcx.ty_to_str(*t)), vtables); let _indenter = indenter(); @@ -454,7 +454,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t, let last = arg_exprs.len() - 1u; 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, + trans_arg_expr(bcx, arg_tys[i], *arg_expr, &mut temp_cleanups, if i == last { ret_flag } else { None }, autoref_arg) }); diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 7896cbbcb56..a7c0bfb81cd 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -192,9 +192,9 @@ type param_substs = {tys: ~[ty::t], fn param_substs_to_str(tcx: ty::ctxt, substs: ¶m_substs) -> ~str { fmt!("param_substs {tys:%?, vtables:%?, bounds:%?}", - substs.tys.map(|t| ty_to_str(tcx, t)), + substs.tys.map(|t| ty_to_str(tcx, *t)), substs.vtables.map(|vs| vs.map(|v| v.to_str(tcx))), - substs.bounds.map(|b| ty::param_bounds_to_str(tcx, b))) + substs.bounds.map(|b| ty::param_bounds_to_str(tcx, *b))) } // Function context. Every LLVM function we create will have one of @@ -1265,7 +1265,7 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] { let params = ty::node_id_to_type_params(tcx, id); match bcx.fcx.param_substs { Some(substs) => { - vec::map(params, |t| ty::subst_tps(tcx, substs.tys, t)) + vec::map(params, |t| ty::subst_tps(tcx, substs.tys, *t)) } _ => params } @@ -1280,7 +1280,7 @@ fn node_vtables(bcx: block, id: ast::node_id) -> Option<typeck::vtable_res> { fn resolve_vtables_in_fn_ctxt(fcx: fn_ctxt, vts: typeck::vtable_res) -> typeck::vtable_res { - @vec::map(*vts, |d| resolve_vtable_in_fn_ctxt(fcx, d)) + @vec::map(*vts, |d| resolve_vtable_in_fn_ctxt(fcx, *d)) } // Apply the typaram substitutions in the fn_ctxt to a vtable. This should @@ -1293,7 +1293,7 @@ fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin) typeck::vtable_static(trait_id, tys, sub) => { let tys = match fcx.param_substs { Some(substs) => { - vec::map(tys, |t| ty::subst_tps(tcx, substs.tys, t)) + vec::map(tys, |t| ty::subst_tps(tcx, substs.tys, *t)) } _ => tys }; diff --git a/src/rustc/middle/trans/consts.rs b/src/rustc/middle/trans/consts.rs index f32fd81775c..a3803ffb91a 100644 --- a/src/rustc/middle/trans/consts.rs +++ b/src/rustc/middle/trans/consts.rs @@ -43,7 +43,7 @@ fn const_vec(cx: @crate_ctxt, e: @ast::expr, es: &[@ast::expr]) let vec_ty = ty::expr_ty(cx.tcx, e); let unit_ty = ty::sequence_element_type(cx.tcx, vec_ty); let llunitty = type_of::type_of(cx, unit_ty); - let v = C_array(llunitty, es.map(|e| const_expr(cx, e))); + let v = C_array(llunitty, es.map(|e| const_expr(cx, *e))); let unit_sz = shape::llsize_of(cx, llunitty); let sz = llvm::LLVMConstMul(C_uint(cx, es.len()), unit_sz); return (v, sz, llunitty); @@ -286,7 +286,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { gv } ast::expr_tup(es) => { - C_struct(es.map(|e| const_expr(cx, e))) + C_struct(es.map(|e| const_expr(cx, *e))) } ast::expr_rec(fs, None) => { C_struct([C_struct( diff --git a/src/rustc/middle/trans/expr.rs b/src/rustc/middle/trans/expr.rs index 27a2ad50223..54604835dae 100644 --- a/src/rustc/middle/trans/expr.rs +++ b/src/rustc/middle/trans/expr.rs @@ -1057,8 +1057,8 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: Dest) -> block { let mut temp_cleanups = ~[]; for vec::eachi(elts) |i, e| { let dest = GEPi(bcx, addr, [0u, i]); - let e_ty = expr_ty(bcx, e); - bcx = trans_into(bcx, e, SaveIn(dest)); + let e_ty = expr_ty(bcx, *e); + bcx = trans_into(bcx, *e, SaveIn(dest)); add_clean_temp_mem(bcx, dest, e_ty); vec::push(temp_cleanups, dest); } diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index 55d4c8fcd9a..7b37305705f 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -420,7 +420,7 @@ fn decl_x86_64_fn(tys: x86_64_tys, let llfn = decl(fnty); for vec::eachi(tys.attrs) |i, a| { - match a { + match *a { option::Some(attr) => { let llarg = get_param(llfn, i); llvm::LLVMAddAttribute(llarg, attr as c_uint); @@ -650,7 +650,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, match tys.x86_64_tys { Some(x86_64) => { for vec::eachi(x86_64.attrs) |i, a| { - match a { + match *a { Some(attr) => { llvm::LLVMAddInstrAttribute( llretval, (i + 1u) as c_uint, diff --git a/src/rustc/middle/trans/meth.rs b/src/rustc/middle/trans/meth.rs index 82843d431a4..a0a207a85d3 100644 --- a/src/rustc/middle/trans/meth.rs +++ b/src/rustc/middle/trans/meth.rs @@ -330,9 +330,9 @@ fn combine_impl_and_methods_tps(bcx: block, vec::tailn(node_substs, node_substs.len() - n_m_tps)); debug!("n_m_tps=%?", n_m_tps); - debug!("rcvr_substs=%?", rcvr_substs.map(|t| bcx.ty_to_str(t))); - debug!("node_substs=%?", node_substs.map(|t| bcx.ty_to_str(t))); - debug!("ty_substs=%?", ty_substs.map(|t| bcx.ty_to_str(t))); + debug!("rcvr_substs=%?", rcvr_substs.map(|t| bcx.ty_to_str(*t))); + debug!("node_substs=%?", node_substs.map(|t| bcx.ty_to_str(*t))); + debug!("ty_substs=%?", ty_substs.map(|t| bcx.ty_to_str(*t))); return ty_substs; } @@ -462,7 +462,7 @@ fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id { } typeck::vtable_trait(trait_id, substs) => { @{def: trait_id, - params: vec::map(substs, |t| mono_precise(t, None))} + params: vec::map(substs, |t| mono_precise(*t, None))} } // can't this be checked at the callee? _ => fail ~"vtable_id" diff --git a/src/rustc/middle/trans/monomorphize.rs b/src/rustc/middle/trans/monomorphize.rs index 7ce79fefa9f..74513357e14 100644 --- a/src/rustc/middle/trans/monomorphize.rs +++ b/src/rustc/middle/trans/monomorphize.rs @@ -22,9 +22,9 @@ fn monomorphic_fn(ccx: @crate_ctxt, let _icx = ccx.insn_ctxt("monomorphic_fn"); let mut must_cast = false; let substs = vec::map(real_substs, |t| { - match normalize_for_monomorphization(ccx.tcx, t) { + match normalize_for_monomorphization(ccx.tcx, *t) { Some(t) => { must_cast = true; t } - None => t + None => *t } }); @@ -40,8 +40,8 @@ fn monomorphic_fn(ccx: @crate_ctxt, #debug["monomorphic_fn(fn_id=%? (%s), real_substs=%?, substs=%?, \ hash_id = %?", fn_id, ty::item_path_str(ccx.tcx, fn_id), - real_substs.map(|s| ty_to_str(ccx.tcx, s)), - substs.map(|s| ty_to_str(ccx.tcx, s)), hash_id]; + real_substs.map(|s| ty_to_str(ccx.tcx, *s)), + substs.map(|s| ty_to_str(ccx.tcx, *s)), hash_id]; match ccx.monomorphized.find(hash_id) { Some(val) => { @@ -256,7 +256,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], }) } None => { - vec::map(substs, |subst| (subst, None)) + vec::map(substs, |subst| (*subst, None)) } }; let param_ids = match param_uses { @@ -298,8 +298,12 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], } }) } - None => precise_param_ids.map(|x| { let (a, b) = x; - mono_precise(a, b) }) + None => { + precise_param_ids.map(|x| { + let (a, b) = *x; + mono_precise(a, b) + }) + } }; @{def: item, params: param_ids} } diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index 8ef9cad4964..4fda4d7264f 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -66,7 +66,7 @@ impl reflector { debug!("passing %u args:", vec::len(args)); let bcx = self.bcx; for args.eachi |i, a| { - debug!("arg %u: %s", i, val_str(bcx.ccx().tn, a)); + debug!("arg %u: %s", i, val_str(bcx.ccx().tn, *a)); } let bool_ty = ty::mk_bool(tcx); let scratch = scratch_datum(bcx, bool_ty, false); @@ -171,7 +171,7 @@ impl reflector { for tys.eachi |i, t| { self.visit(~"tup_field", ~[self.c_uint(i), - self.c_tydesc(t)]); + self.c_tydesc(*t)]); } } } @@ -263,7 +263,7 @@ impl reflector { for v.args.eachi |j, a| { self.visit(~"enum_variant_field", ~[self.c_uint(j), - self.c_tydesc(a)]); + self.c_tydesc(*a)]); } } } diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 54cc640cebf..46fd9cefb7f 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -72,7 +72,7 @@ impl nominal_id_ : to_bytes::IterBytes { fn mk_nominal_id(tcx: ty::ctxt, did: ast::def_id, parent_id: Option<ast::def_id>, tps: ~[ty::t]) -> nominal_id { - let tps_norm = tps.map(|t| ty::normalize_ty(tcx, t)); + let tps_norm = tps.map(|t| ty::normalize_ty(tcx, *t)); @{did: did, parent_id: parent_id, tps: tps_norm} } diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index 31eeedae104..10f93626280 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -329,7 +329,7 @@ fn write_content(bcx: block, let lleltptr = GEPi(bcx, lldest, [i]); debug!("writing index %? with lleltptr=%?", i, bcx.val_str(lleltptr)); - bcx = expr::trans_into(bcx, element, + bcx = expr::trans_into(bcx, *element, SaveIn(lleltptr)); add_clean_temp_mem(bcx, lleltptr, vt.unit_ty); vec::push(temp_cleanups, lleltptr); diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index ac1692d6c33..d9032f8ce90 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -31,7 +31,7 @@ fn type_of_explicit_arg(ccx: @crate_ctxt, arg: ty::arg) -> TypeRef { } fn type_of_explicit_args(ccx: @crate_ctxt, inputs: ~[ty::arg]) -> ~[TypeRef] { - inputs.map(|arg| type_of_explicit_arg(ccx, arg)) + inputs.map(|arg| type_of_explicit_arg(ccx, *arg)) } fn type_of_fn(cx: @crate_ctxt, inputs: ~[ty::arg], diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index ca8680fd8d5..d18c48ae94d 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -1235,7 +1235,7 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty { fn fold_substs(substs: &substs, fldop: fn(t) -> t) -> substs { {self_r: substs.self_r, self_ty: substs.self_ty.map(|t| fldop(t)), - tps: substs.tps.map(|t| fldop(t))} + tps: substs.tps.map(|t| fldop(*t))} } match *sty { @@ -1269,7 +1269,7 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty { ty_rec(new_fields) } ty_tup(ts) => { - let new_ts = vec::map(ts, |tt| fldop(tt)); + let new_ts = vec::map(ts, |tt| fldop(*tt)); ty_tup(new_ts) } ty_fn(ref f) => { @@ -1332,7 +1332,7 @@ fn fold_regions_and_ty( {self_r: substs.self_r.map(|r| fldr(r)), self_ty: substs.self_ty.map(|t| fldt(t)), - tps: substs.tps.map(|t| fldt(t))} + tps: substs.tps.map(|t| fldt(*t))} } let tb = ty::get(ty); @@ -1476,7 +1476,7 @@ fn param_bound_to_str(cx: ctxt, pb: ¶m_bound) -> ~str { } fn param_bounds_to_str(cx: ctxt, pbs: param_bounds) -> ~str { - fmt!("%?", pbs.map(|pb| param_bound_to_str(cx, &pb))) + fmt!("%?", pbs.map(|pb| param_bound_to_str(cx, pb))) } fn subst(cx: ctxt, @@ -3487,11 +3487,11 @@ fn substd_enum_variants(cx: ctxt, substs: &substs) -> ~[variant_info] { do vec::map(*enum_variants(cx, id)) |variant_info| { let substd_args = vec::map(variant_info.args, - |aty| subst(cx, substs, aty)); + |aty| subst(cx, substs, *aty)); let substd_ctor_ty = subst(cx, substs, variant_info.ctor_ty); - @{args: substd_args, ctor_ty: substd_ctor_ty,.. *variant_info} + @{args: substd_args, ctor_ty: substd_ctor_ty, ..**variant_info} } } diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 20c12c25cca..a01dbb881c5 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -163,7 +163,7 @@ impl vtable_origin { vtable_trait(def_id, ref tys) => { fmt!("vtable_trait(%?:%s, %?)", def_id, ty::item_path_str(tcx, def_id), - tys.map(|t| ty_to_str(tcx, t))) + tys.map(|t| ty_to_str(tcx, *t))) } } } @@ -202,7 +202,7 @@ fn write_substs_to_tcx(tcx: ty::ctxt, +substs: ~[ty::t]) { if substs.len() > 0u { debug!("write_substs_to_tcx(%d, %?)", node_id, - substs.map(|t| ty_to_str(tcx, t))); + substs.map(|t| ty_to_str(tcx, *t))); tcx.node_type_substs.insert(node_id, substs); } } diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index b38a4b22675..0c474994553 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -125,7 +125,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope Copy Owned>( fmt!("wrong number of type arguments: expected %u but found %u", (*decl_bounds).len(), path.types.len())); } - let tps = path.types.map(|a_t| ast_ty_to_ty(self, rscope, a_t)); + let tps = path.types.map(|a_t| ast_ty_to_ty(self, rscope, *a_t)); let substs = {self_r:self_r, self_ty:None, tps:tps}; {substs: substs, ty: ty::subst(tcx, &substs, decl_ty)} @@ -295,7 +295,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope Copy Owned>( |tmt| ty::mk_rptr(tcx, r, tmt)) } ast::ty_tup(fields) => { - let flds = vec::map(fields, |t| ast_ty_to_ty(self, rscope, t)); + let flds = vec::map(fields, |t| ast_ty_to_ty(self, rscope, *t)); ty::mk_tup(tcx, flds) } ast::ty_rec(fields) => { @@ -489,7 +489,7 @@ fn ty_of_fn_decl<AC: ast_conv, RS: region_scope Copy Owned>( // were supplied if i < e.inputs.len() {Some(e.inputs[i])} else {None} }; - ty_of_arg(self, rb, a, expected_arg_ty) + ty_of_arg(self, rb, *a, expected_arg_ty) }; let expected_ret_ty = expected_tys.map(|e| e.output); diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 932e32762a6..85465eb7d3c 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -237,7 +237,7 @@ fn check_fn(ccx: @crate_ctxt, let ret_ty = fn_ty.sig.output; debug!("check_fn(arg_tys=%?, ret_ty=%?, self_info.self_ty=%?)", - arg_tys.map(|a| ty_to_str(tcx, a)), + arg_tys.map(|a| ty_to_str(tcx, *a)), ty_to_str(tcx, ret_ty), option::map(self_info, |s| ty_to_str(tcx, s.self_ty))); @@ -1067,8 +1067,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } bot |= check_expr_with_unifier( - fcx, arg, Some(formal_ty), - || demand::assign(fcx, arg.span, formal_ty, arg) + fcx, *arg, Some(formal_ty), + || demand::assign(fcx, arg.span, formal_ty, *arg) ); } } @@ -1419,7 +1419,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, _ => () } - let tps = vec::map(tys, |ty| fcx.to_ty(ty)); + let tps = vec::map(tys, |ty| fcx.to_ty(*ty)); match method::lookup(fcx, expr, base, expr.id, field, expr_t, tps) { @@ -1853,16 +1853,13 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fcx.write_ty(id, t); } ast::expr_tup(elts) => { - let mut elt_ts = ~[]; - vec::reserve(elt_ts, vec::len(elts)); let flds = unpack_expected(fcx, expected, |sty| { match sty { ty::ty_tup(flds) => Some(flds), _ => None } }); - for elts.eachi |i, e| { - check_expr(fcx, e, flds.map(|fs| fs[i])); - let ety = fcx.expr_ty(e); - vec::push(elt_ts, ety); - } + let elt_ts = do elts.mapi |i, e| { + check_expr(fcx, *e, flds.map(|fs| fs[i])); + fcx.expr_ty(*e) + }; let typ = ty::mk_tup(tcx, elt_ts); fcx.write_ty(id, typ); } @@ -1886,7 +1883,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, }); match base { None => { - fn get_node(f: spanned<field>) -> field { f.node } + fn get_node(f: &spanned<field>) -> field { f.node } let typ = ty::mk_rec(tcx, vec::map(fields_t, get_node)); fcx.write_ty(id, typ); /* Check for duplicate fields */ @@ -2491,7 +2488,7 @@ fn instantiate_path(fcx: @fn_ctxt, (span, ~"not enough type parameters provided for this item"); fcx.infcx().next_ty_vars(ty_param_count) } else { - pth.types.map(|aty| fcx.to_ty(aty)) + pth.types.map(|aty| fcx.to_ty(*aty)) }; let substs = {self_r: self_r, self_ty: None, tps: tps}; @@ -2576,7 +2573,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt, }); for tps_used.eachi |i, b| { - if !b { + if !*b { ccx.tcx.sess.span_err( span, fmt!("type parameter `%s` is unused", ccx.tcx.sess.str_of(tps[i].ident))); diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index 77d1ce4f774..14de7871e91 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -145,7 +145,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, let vinfo = ty::enum_variant_with_id( tcx, v_def_ids.enm, v_def_ids.var); - vinfo.args.map(|t| { ty::subst(tcx, expected_substs, t) }) + vinfo.args.map(|t| { ty::subst(tcx, expected_substs, *t) }) }; let arg_len = arg_types.len(), subpats_len = match subpats { None => arg_len, diff --git a/src/rustc/middle/typeck/check/regionmanip.rs b/src/rustc/middle/typeck/check/regionmanip.rs index 64065a5bd35..d969ce908f0 100644 --- a/src/rustc/middle/typeck/check/regionmanip.rs +++ b/src/rustc/middle/typeck/check/regionmanip.rs @@ -39,7 +39,7 @@ fn replace_bound_regions_in_fn_ty( all_tys=%?)", self_ty.map(|t| ty_to_str(tcx, t)), ty_to_str(tcx, ty::mk_fn(tcx, *fn_ty)), - all_tys.map(|t| ty_to_str(tcx, t))); + all_tys.map(|t| ty_to_str(tcx, *t))); let _i = indenter(); let isr = do create_bound_region_mapping(tcx, isr, all_tys) |br| { diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index d984ca1a18a..3c58eb57189 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -164,7 +164,7 @@ fn get_enum_variant_types(ccx: @crate_ctxt, fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id, trait_ty: ty::t) { fn store_methods<T>(ccx: @crate_ctxt, id: ast::node_id, - stuff: ~[T], f: fn@(T) -> ty::method) { + stuff: ~[T], f: fn@(v: &T) -> ty::method) { ty::store_trait_methods(ccx.tcx, id, @vec::map(stuff, f)); } @@ -213,7 +213,7 @@ fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id, trait_ty: ty::t) { ast_map::node_item(@{node: ast::item_trait(params, _, ms), _}, _) => { store_methods::<ast::trait_method>(ccx, id, ms, |m| { let trait_bounds = ty_param_bounds(ccx, params); - let ty_m = trait_method_to_ty_method(m); + let ty_m = trait_method_to_ty_method(*m); let method_ty = ty_of_ty_method(ccx, ty_m, region_paramd); if ty_m.self_ty.node == ast::sty_static { make_static_method_ty(ccx, ty_m, region_paramd, @@ -226,7 +226,7 @@ fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id, trait_ty: ty::t) { // All methods need to be stored, since lookup_method // relies on the same method cache for self-calls store_methods::<@ast::method>(ccx, id, struct_def.methods, |m| { - ty_of_method(ccx, m, region_paramd) + ty_of_method(ccx, *m, region_paramd) }); } _ => { /* Ignore things that aren't traits or classes */ } @@ -413,7 +413,7 @@ fn convert_methods(ccx: @crate_ctxt, let tcx = ccx.tcx; do vec::map(ms) |m| { let bounds = ty_param_bounds(ccx, m.tps); - let mty = ty_of_method(ccx, m, rp); + let mty = ty_of_method(ccx, *m, rp); let fty = ty::mk_fn(tcx, mty.fty); tcx.tcache.insert( local_def(m.id), @@ -500,7 +500,7 @@ fn convert_struct(ccx: @crate_ctxt, do option::iter(struct_def.ctor) |ctor| { // Write the ctor type let t_args = ctor.node.dec.inputs.map( - |a| ty_of_arg(ccx, type_rscope(rp), a, None) ); + |a| ty_of_arg(ccx, type_rscope(rp), *a, None) ); let t_res = ty::mk_class( tcx, local_def(id), {self_r: rscope::bound_self_region(rp), @@ -772,7 +772,7 @@ fn ty_of_foreign_fn_decl(ccx: @crate_ctxt, let bounds = ty_param_bounds(ccx, ty_params); let rb = in_binding_rscope(empty_rscope); - let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, rb, a, None) ); + let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, rb, *a, None) ); let output_ty = ast_ty_to_ty(ccx, rb, decl.output); let t_fn = ty::mk_fn(ccx.tcx, FnTyBase { diff --git a/src/rustc/middle/typeck/infer/region_var_bindings.rs b/src/rustc/middle/typeck/infer/region_var_bindings.rs index de990464125..664c2d37d3c 100644 --- a/src/rustc/middle/typeck/infer/region_var_bindings.rs +++ b/src/rustc/middle/typeck/infer/region_var_bindings.rs @@ -877,8 +877,7 @@ impl RegionVarBindings { }); // It would be nice to write this using map(): - let mut edges = ~[]; - vec::reserve(edges, num_edges); + let mut edges = vec::with_capacity(num_edges); for self.constraints.each_ref |constraint, span| { vec::push(edges, GraphEdge { next_edge: [mut uint::max_value, uint::max_value], diff --git a/src/rustc/middle/typeck/infer/sub.rs b/src/rustc/middle/typeck/infer/sub.rs index 359b8eea741..e6bcdf3e71f 100644 --- a/src/rustc/middle/typeck/infer/sub.rs +++ b/src/rustc/middle/typeck/infer/sub.rs @@ -139,10 +139,7 @@ impl Sub: combine { // anything to do with the region variable that's created // for it. The only thing we're doing with `br` here is // using it in the debug message. - // - // NDM--we should not be used dummy_sp() here, but - // rather passing in the span or something like that. - let rvar = self.infcx.next_region_var_nb(dummy_sp()); + let rvar = self.infcx.next_region_var_nb(self.span); debug!("Bound region %s maps to %s", bound_region_to_str(self.infcx.tcx, br), region_to_str(self.infcx.tcx, rvar)); diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 17af1fd565b..9ade20c5568 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -236,7 +236,7 @@ fn expr_repr(cx: ctxt, expr: @ast::expr) -> ~str { } fn tys_to_str(cx: ctxt, ts: ~[t]) -> ~str { - let tstrs = ts.map(|t| ty_to_str(cx, t)); + let tstrs = ts.map(|t| ty_to_str(cx, *t)); fmt!("[%s]", str::connect(tstrs, ", ")) } @@ -394,7 +394,7 @@ fn parameterized(cx: ctxt, }; if vec::len(tps) > 0u { - let strs = vec::map(tps, |t| ty_to_str(cx, t) ); + let strs = vec::map(tps, |t| ty_to_str(cx, *t)); fmt!("%s%s<%s>", base, r_str, str::connect(strs, ~",")) } else { fmt!("%s%s", base, r_str) |
