about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-30 21:14:13 -0700
committerbors <bors@rust-lang.org>2013-06-30 21:14:13 -0700
commit07feeb95c5e73c5d871c7e365cf4a7138774d449 (patch)
tree8b7f2a06b1a86a57dc3bc00bb53da5e96b1a243b /src/libsyntax
parentd5c5ce3f8d07ba7f9059727a790ce19f7a1599b7 (diff)
parentc0a20d2929a7c0d6af0de899198df4f26453d877 (diff)
downloadrust-07feeb95c5e73c5d871c7e365cf4a7138774d449.tar.gz
rust-07feeb95c5e73c5d871c7e365cf4a7138774d449.zip
auto merge of #7487 : huonw/rust/vec-kill, r=cmr
Continuation of #7430.

I haven't removed the `map` method, since the replacement `v.iter().transform(f).collect::<~[SomeType]>()` is a little ridiculous at the moment.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast_util.rs2
-rw-r--r--src/libsyntax/ext/deriving/decodable.rs8
-rw-r--r--src/libsyntax/ext/deriving/generic.rs11
-rw-r--r--src/libsyntax/ext/deriving/rand.rs4
-rw-r--r--src/libsyntax/ext/pipes/pipec.rs12
-rw-r--r--src/libsyntax/ext/source_util.rs5
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs3
-rw-r--r--src/libsyntax/fold.rs13
8 files changed, 27 insertions, 31 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index ee7c7180f8d..529d5bfe70b 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -814,7 +814,7 @@ mod test {
     // convert a list of uints to an @[ident]
     // (ignores the interner completely)
     fn uints_to_idents (uints: &~[uint]) -> @~[ident] {
-        @uints.map(|u|{ ident {name:*u, ctxt: empty_ctxt} })
+        @uints.map(|u| ident {name:*u, ctxt: empty_ctxt})
     }
 
     fn id (u : uint, s: SyntaxContext) -> ident {
diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs
index 77dbd96255d..405f9e3438b 100644
--- a/src/libsyntax/ext/deriving/decodable.rs
+++ b/src/libsyntax/ext/deriving/decodable.rs
@@ -91,9 +91,9 @@ fn decodable_substructure(cx: @ExtCtxt, span: span,
                     }
                 }
                 Right(ref fields) => {
-                    let fields = do fields.mapi |i, f| {
+                    let fields = do fields.iter().enumerate().transform |(i, f)| {
                         cx.field_imm(span, *f, getarg(cx.str_of(*f), i))
-                    };
+                    }.collect();
                     cx.expr_struct_ident(span, substr.type_ident, fields)
                 }
             };
@@ -133,9 +133,9 @@ fn decodable_substructure(cx: @ExtCtxt, span: span,
                         }
                     }
                     Right(ref fields) => {
-                        let fields = do fields.mapi |i, f| {
+                        let fields = do fields.iter().enumerate().transform |(i, f)| {
                             cx.field_imm(span, *f, getarg(i))
-                        };
+                        }.collect();
                         cx.expr_struct_ident(span, name, fields)
                     }
                 };
diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs
index 10d9f878bc4..0e4fc9d96fa 100644
--- a/src/libsyntax/ext/deriving/generic.rs
+++ b/src/libsyntax/ext/deriving/generic.rs
@@ -591,14 +591,14 @@ impl<'self> MethodDef<'self> {
         // transpose raw_fields
         let fields = match raw_fields {
             [self_arg, .. rest] => {
-                do self_arg.mapi |i, &(opt_id, field)| {
+                do self_arg.iter().enumerate().transform |(i, &(opt_id, field))| {
                     let other_fields = do rest.map |l| {
                         match &l[i] {
                             &(_, ex) => ex
                         }
                     };
                     (opt_id, field, other_fields)
-                }
+                }.collect()
             }
             [] => { cx.span_bug(span, "No self arguments to non-static \
                                        method in generic `deriving`") }
@@ -745,10 +745,11 @@ impl<'self> MethodDef<'self> {
                         }
                     }
                     let field_tuples =
-                        do vec::map_zip(*self_vec,
-                                        enum_matching_fields) |&(id, self_f), &other| {
+                        do self_vec.iter()
+                           .zip(enum_matching_fields.iter())
+                           .transform |(&(id, self_f), &other)| {
                         (id, self_f, other)
-                    };
+                    }.collect();
                     substructure = EnumMatching(variant_index, variant, field_tuples);
                 }
                 None => {
diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs
index 19aa29a62a9..cc2050d9bd7 100644
--- a/src/libsyntax/ext/deriving/rand.rs
+++ b/src/libsyntax/ext/deriving/rand.rs
@@ -91,7 +91,7 @@ fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
             let rand_variant = cx.expr_binary(span, ast::rem,
                                               rv_call, variant_count);
 
-            let mut arms = do variants.mapi |i, id_sum| {
+            let mut arms = do variants.iter().enumerate().transform |(i, id_sum)| {
                 let i_expr = cx.expr_uint(span, i);
                 let pat = cx.pat_lit(span, i_expr);
 
@@ -102,7 +102,7 @@ fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
                                rand_thing(cx, span, ident, summary, || rand_call()))
                     }
                 }
-            };
+            }.collect::<~[ast::arm]>();
 
             // _ => {} at the end. Should never occur
             arms.push(cx.arm_unreachable(span));
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs
index 3044cd50b34..0e24725ea99 100644
--- a/src/libsyntax/ext/pipes/pipec.rs
+++ b/src/libsyntax/ext/pipes/pipec.rs
@@ -54,8 +54,9 @@ impl gen_send for message {
             let next = this.proto.get_state(next_state.state);
             assert!(next_state.tys.len() ==
                 next.generics.ty_params.len());
-            let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
-            let args_ast = vec::map_zip(arg_names, *tys, |n, t| cx.arg(span, *n, *t));
+            let arg_names = vec::from_fn(tys.len(), |i| cx.ident_of("x_"+i.to_str()));
+            let args_ast: ~[ast::arg] = arg_names.iter().zip(tys.iter())
+                .transform(|(n, t)| cx.arg(span, *n, *t)).collect();
 
             let pipe_ty = cx.ty_path(
                 path(~[this.data_name()], span)
@@ -133,11 +134,10 @@ impl gen_send for message {
 
             message(ref _id, span, ref tys, this, None) => {
                 debug!("pipec: no next state");
-                let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str()));
+                let arg_names = vec::from_fn(tys.len(), |i| "x_" + i.to_str());
 
-                let args_ast = do vec::map_zip(arg_names, *tys) |n, t| {
-                    cx.arg(span, cx.ident_of(*n), *t)
-                };
+                let args_ast: ~[ast::arg] = arg_names.iter().zip(tys.iter())
+                    .transform(|(n, t)| cx.arg(span, cx.ident_of(*n), *t)).collect();
 
                 let args_ast = vec::append(
                     ~[cx.arg(span,
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index 71dc82be414..f6325c2eb2c 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -21,7 +21,6 @@ use print::pprust;
 
 use std::io;
 use std::result;
-use std::vec;
 
 // These macros all relate to the file system; they either return
 // the column/row/filename of the expression, or they include
@@ -106,9 +105,7 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
     let file = get_single_str_from_tts(cx, sp, tts, "include_bin!");
     match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) {
       result::Ok(src) => {
-        let u8_exprs = vec::map(src, |char| {
-            cx.expr_u8(sp, *char)
-        });
+        let u8_exprs: ~[@ast::expr] = src.iter().transform(|char| cx.expr_u8(sp, *char)).collect();
         base::MRExpr(cx.expr_vec(sp, u8_exprs))
       }
       result::Err(ref e) => {
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 7c69bdd01c8..cddba358373 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -326,8 +326,7 @@ pub fn parse(
                         cur_eis.push(new_ei);
                     }
 
-                    let matches = vec::map(ei.matches, // fresh, same size:
-                                           |_m| ~[]);
+                    let matches = vec::from_elem(ei.matches.len(), ~[]);
                     let ei_t = ei;
                     cur_eis.push(~MatcherPos {
                         elts: copy *matchers,
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 2fc111da453..4e145123996 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -699,7 +699,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ {
 // ...nor do modules
 pub fn noop_fold_mod(m: &_mod, fld: @ast_fold) -> _mod {
     ast::_mod {
-        view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)),
+        view_items: m.view_items.iter().transform(|x| fld.fold_view_item(*x)).collect(),
         items: vec::filter_mapped(m.items, |x| fld.fold_item(*x)),
     }
 }
@@ -708,8 +708,8 @@ fn noop_fold_foreign_mod(nm: &foreign_mod, fld: @ast_fold) -> foreign_mod {
     ast::foreign_mod {
         sort: nm.sort,
         abis: nm.abis,
-        view_items: vec::map(nm.view_items, |x| fld.fold_view_item(*x)),
-        items: vec::map(nm.items, |x| fld.fold_foreign_item(*x)),
+        view_items: nm.view_items.iter().transform(|x| fld.fold_view_item(*x)).collect(),
+        items: nm.items.iter().transform(|x| fld.fold_foreign_item(*x)).collect(),
     }
 }
 
@@ -728,8 +728,8 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
         }
         struct_variant_kind(struct_def) => {
             kind = struct_variant_kind(@ast::struct_def {
-                fields: vec::map(struct_def.fields,
-                                 |f| fld.fold_struct_field(*f)),
+                fields: struct_def.fields.iter()
+                    .transform(|f| fld.fold_struct_field(*f)).collect(),
                 ctor_id: struct_def.ctor_id.map(|c| fld.new_id(*c))
             })
         }
@@ -824,8 +824,7 @@ impl ast_fold for AstFoldFns {
        @view_item {
         @ast::view_item {
             node: (self.fold_view_item)(&x.node, self as @ast_fold),
-            attrs: vec::map(x.attrs, |a|
-                  fold_attribute_(*a, self as @ast_fold)),
+            attrs: x.attrs.iter().transform(|a| fold_attribute_(*a, self as @ast_fold)).collect(),
             vis: x.vis,
             span: (self.new_span)(x.span),
         }