diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 92315285d043c240dd254c8b5f4171fdccd80126..77f7b5023dfa97839cba366780738bbc51b3d750 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -119,8 +119,8 @@ fn chars_from_bytes(bytes: &~[u8], chars: &mut ~[char]) } return (i, 0); } - let mut bytes: ~[u8] = ~[]; - let mut chars: ~[char] = ~[]; + let mut bytes = ~[]; + let mut chars = ~[]; // might need more bytes, but reading n will never over-read let mut nbread = n; while nbread > 0 { diff --git a/src/libcore/logging.rs b/src/libcore/logging.rs index d4f3c0ea272ed5b2b52d6e2b9f0e05e420cd825c..958d1ac56ea78101e7911f5f542c7b28b90ac6cd 100644 --- a/src/libcore/logging.rs +++ b/src/libcore/logging.rs @@ -32,7 +32,7 @@ pub fn console_off() { #[cfg(notest)] #[lang="log_type"] pub fn log_type(level: u32, object: &T) { - let bytes = do io::with_bytes_writer() |writer| { + let bytes = do io::with_bytes_writer |writer| { repr::write_repr(writer, object); }; unsafe { diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index ff29953f09a49fbe036b15fa862dce08082e0fa7..b246adcb1d7cddb6bc0a452c2596239ac80d5fd7 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -559,7 +559,7 @@ fn log_simple() -> bool { unsafe { self.align(sys::min_align_of::()); let value_addr: &T = transmute(copy self.ptr); - (*value_addr).write_repr(self.writer); + value_addr.write_repr(self.writer); self.bump(sys::size_of::()); true } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index d08edd7af1d07fd7ea174db5454d4d9b74284404..4bd1679600ffbe917029aad14cbcfa3c8e47a4b4 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -90,9 +90,7 @@ fn attr_meta(attr: ast::attribute) -> @ast::meta_item { @attr.node.value } // Get the meta_items from inside a vector of attributes fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { - let mut mitems = ~[]; - for attrs.each |a| { mitems.push(attr_meta(*a)); } - return mitems; + do attrs.map |a| { attr_meta(*a) } } fn desugar_doc_attr(attr: &ast::attribute) -> ast::attribute { diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index a2c864f6f465fc6d4f79575a9036531852b6d284..45e7cd4e9d45a47496e9e8ea92a04254ea83643f 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -27,8 +27,7 @@ fn declare_upcalls(targ_cfg: @session::config, fn decl(llmod: ModuleRef, prefix: ~str, name: ~str, tys: ~[TypeRef], rv: TypeRef) -> ValueRef { - let mut arg_tys: ~[TypeRef] = ~[]; - for tys.each |t| { arg_tys.push(*t); } + let arg_tys = tys.map(|t| *t); let fn_ty = T_fn(arg_tys, rv); return base::decl_cdecl_fn(llmod, prefix + name, fn_ty); } diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index f0911bd1aa27ac7abf0e2817166c79df6ca0bf0e..1656efbd9668430bdd675309ce0db5fa19c629d0 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -598,13 +598,12 @@ fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id, let ctor_ty = item_type({crate: cdata.cnum, node: id}, item, tcx, cdata); let name = item_name(intr, item); - let mut arg_tys: ~[ty::t] = ~[]; - match ty::get(ctor_ty).sty { - ty::ty_fn(f) => { - for f.sig.inputs.each |a| { arg_tys.push(a.ty); } - } - _ => { /* Nullary enum variant. */ } - } + let arg_tys = match ty::get(ctor_ty).sty { + ty::ty_fn(f) => f.sig.inputs.map(|a| a.ty), + + // Nullary enum variant. + _ => ~[], + }; match variant_disr_val(item) { Some(val) => { disr_val = val; } _ => { /* empty */ } diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index 0c6ec267da81281a43ad96bb4f988b34f4368561..123905adba11b7ffaba7424967a53ebe8a15a408 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -34,9 +34,7 @@ fn indenter() -> _indenter { fn field_expr(f: ast::field) -> @ast::expr { return f.node.expr; } fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] { - let mut es = ~[]; - for fields.each |f| { es.push(f.node.expr); } - return es; + fields.map(|f| f.node.expr) } // Takes a predicate p, returns true iff p is true for any subexpressions diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 27ace283fa0ce7a75810d372b7be9ec2904c2ab1..8207082cf20e69d87142b07ad409d52da04b9272 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -282,8 +282,7 @@ fn fn_to_str(cx: ctxt, purity: ast::purity, proto: ty::fn_proto, _ => { } } s += ~"("; - let mut strs = ~[]; - for inputs.each |a| { strs.push(fn_input_to_str(cx, *a)); } + let strs = inputs.map(|a| fn_input_to_str(cx, *a)); s += str::connect(strs, ~", "); s += ~")"; if ty::get(output).sty != ty_nil { @@ -338,13 +337,11 @@ fn field_to_str(cx: ctxt, f: field) -> ~str { ty_unboxed_vec(tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" } ty_type => ~"type", ty_rec(elems) => { - let mut strs: ~[~str] = ~[]; - for elems.each |fld| { strs.push(field_to_str(cx, *fld)); } + let strs = elems.map(|fld| field_to_str(cx, *fld)); ~"{" + str::connect(strs, ~",") + ~"}" } ty_tup(elems) => { - let mut strs = ~[]; - for elems.each |elem| { strs.push(ty_to_str(cx, *elem)); } + let strs = elems.map(|elem| ty_to_str(cx, *elem)); ~"(" + str::connect(strs, ~",") + ~")" } ty_fn(ref f) => {