about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-06-17 19:43:22 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-06-21 03:20:22 -0400
commit49c74524e2c5a2a81ce4cbe2c50a507c0be9f24e (patch)
tree441c718864c414bd4f7750c2435edc100e4a1841 /src/libsyntax
parentcbad1da3db7eda0911e988fb6255ac5c16961aa7 (diff)
downloadrust-49c74524e2c5a2a81ce4cbe2c50a507c0be9f24e.tar.gz
rust-49c74524e2c5a2a81ce4cbe2c50a507c0be9f24e.zip
vec: rm old_iter implementations, except BaseIter
The removed test for issue #2611 is well covered by the `std::iterator`
module itself.

This adds the `count` method to `IteratorUtil` to replace `EqIter`.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/abi.rs4
-rw-r--r--src/libsyntax/attr.rs2
-rw-r--r--src/libsyntax/diagnostic.rs2
-rw-r--r--src/libsyntax/ext/concat_idents.rs2
-rw-r--r--src/libsyntax/ext/deriving/decodable.rs2
-rw-r--r--src/libsyntax/ext/deriving/encodable.rs4
-rw-r--r--src/libsyntax/ext/deriving/generic.rs8
-rw-r--r--src/libsyntax/ext/expand.rs6
-rw-r--r--src/libsyntax/ext/pipes/liveness.rs8
-rw-r--r--src/libsyntax/ext/pipes/pipec.rs12
-rw-r--r--src/libsyntax/ext/pipes/proto.rs12
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs2
-rw-r--r--src/libsyntax/print/pprust.rs6
13 files changed, 35 insertions, 35 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs
index 53729dbd115..943a38a337f 100644
--- a/src/libsyntax/abi.rs
+++ b/src/libsyntax/abi.rs
@@ -211,7 +211,7 @@ impl AbiSet {
         let mut abis = ~[];
         for self.each |abi| { abis.push(abi); }
 
-        for abis.eachi |i, abi| {
+        for abis.iter().enumerate().advance |(i, abi)| {
             let data = abi.data();
             for abis.slice(0, i).each |other_abi| {
                 let other_data = other_abi.data();
@@ -374,7 +374,7 @@ fn abi_to_str_rust() {
 
 #[test]
 fn indices_are_correct() {
-    for AbiDatas.eachi |i, abi_data| {
+    for AbiDatas.iter().enumerate().advance |(i, abi_data)| {
         assert!(i == abi_data.abi.index());
     }
 
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index e096711262f..96e05fd2beb 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -194,7 +194,7 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
             ast::meta_list(ref nb, ref misb) => {
                 if na != nb { return false; }
                 for misa.each |mi| {
-                    if !misb.contains(mi) { return false; }
+                    if !misb.iter().any_(|x| x == mi) { return false; }
                 }
                 true
             }
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs
index e67ca5260b8..249c1c79a37 100644
--- a/src/libsyntax/diagnostic.rs
+++ b/src/libsyntax/diagnostic.rs
@@ -246,7 +246,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
     let mut elided = false;
     let mut display_lines = /* FIXME (#2543) */ copy lines.lines;
     if display_lines.len() > max_lines {
-        display_lines = vec::slice(display_lines, 0u, max_lines).to_vec();
+        display_lines = vec::slice(display_lines, 0u, max_lines).to_owned();
         elided = true;
     }
     // Print the offending lines
diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs
index bfb234106b8..e7fb15fbd51 100644
--- a/src/libsyntax/ext/concat_idents.rs
+++ b/src/libsyntax/ext/concat_idents.rs
@@ -20,7 +20,7 @@ use parse::token::{str_to_ident};
 pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
     -> base::MacResult {
     let mut res_str = ~"";
-    for tts.eachi |i, e| {
+    for tts.iter().enumerate().advance |(i, e)| {
         if i & 1 == 1 {
             match *e {
                 ast::tt_tok(_, token::COMMA) => (),
diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs
index abea7912fc8..7d17f436a41 100644
--- a/src/libsyntax/ext/deriving/decodable.rs
+++ b/src/libsyntax/ext/deriving/decodable.rs
@@ -111,7 +111,7 @@ fn decodable_substructure(cx: @ExtCtxt, span: span,
             let mut variants = ~[];
             let rvariant_arg = cx.ident_of("read_enum_variant_arg");
 
-            for fields.eachi |i, f| {
+            for fields.iter().enumerate().advance |(i, f)| {
                 let (name, parts) = match *f { (i, ref p) => (i, p) };
                 variants.push(cx.expr_str(span, cx.str_of(name)));
 
diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs
index d7e64caa5c8..2b73dc24d33 100644
--- a/src/libsyntax/ext/deriving/encodable.rs
+++ b/src/libsyntax/ext/deriving/encodable.rs
@@ -124,7 +124,7 @@ fn encodable_substructure(cx: @ExtCtxt, span: span,
         Struct(ref fields) => {
             let emit_struct_field = cx.ident_of("emit_struct_field");
             let mut stmts = ~[];
-            for fields.eachi |i, f| {
+            for fields.iter().enumerate().advance |(i, f)| {
                 let (name, val) = match *f {
                     (Some(id), e, _) => (cx.str_of(id), e),
                     (None, e, _) => (fmt!("_field%u", i).to_managed(), e)
@@ -155,7 +155,7 @@ fn encodable_substructure(cx: @ExtCtxt, span: span,
             let encoder = cx.expr_ident(span, blkarg);
             let emit_variant_arg = cx.ident_of("emit_enum_variant_arg");
             let mut stmts = ~[];
-            for fields.eachi |i, f| {
+            for fields.iter().enumerate().advance |(i, f)| {
                 let val = match *f { (_, e, _) => e };
                 let enc = cx.expr_method_call(span, val, encode, ~[blkencoder]);
                 let lambda = cx.lambda_expr_1(span, enc, blkarg);
diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs
index 22ce305b857..d44d4668299 100644
--- a/src/libsyntax/ext/deriving/generic.rs
+++ b/src/libsyntax/ext/deriving/generic.rs
@@ -487,7 +487,7 @@ impl<'self> MethodDef<'self> {
             None => respan(span, ast::sty_static),
         };
 
-        for self.args.eachi |i, ty| {
+        for self.args.iter().enumerate().advance |(i, ty)| {
             let ast_ty = ty.to_ty(cx, span, type_ident, generics);
             let ident = cx.ident_of(fmt!("__arg_%u", i));
             arg_tys.push((ident, ast_ty));
@@ -741,7 +741,7 @@ impl<'self> MethodDef<'self> {
                     let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]);
 
                     for matches_so_far.tail().each |&(_, _, other_fields)| {
-                        for other_fields.eachi |i, &(_, other_field)| {
+                        for other_fields.iter().enumerate().advance |(i, &(_, other_field))| {
                             enum_matching_fields[i].push(other_field);
                         }
                     }
@@ -809,7 +809,7 @@ impl<'self> MethodDef<'self> {
                 }
             } else {
                 // create an arm matching on each variant
-                for enum_def.variants.eachi |index, variant| {
+                for enum_def.variants.iter().enumerate().advance |(index, variant)| {
                     let (pattern, idents) = create_enum_variant_pattern(cx, span,
                                                                        variant,
                                                                        current_match_str,
@@ -923,7 +923,7 @@ fn create_struct_pattern(cx: @ExtCtxt,
     let mut ident_expr = ~[];
     let mut struct_type = Unknown;
 
-    for struct_def.fields.eachi |i, struct_field| {
+    for struct_def.fields.iter().enumerate().advance |(i, struct_field)| {
         let opt_id = match struct_field.node.kind {
             ast::named_field(ident, _) if (struct_type == Unknown ||
                                            struct_type == Record) => {
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 2e7e8240bc0..f6504e85b43 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -200,7 +200,7 @@ pub fn expand_item(extsbox: @mut SyntaxEnv,
 
 // does this attribute list contain "macro_escape" ?
 pub fn contains_macro_escape (attrs: &[ast::attribute]) -> bool {
-    attrs.any(|attr| "macro_escape" == attr::get_attr_name(attr))
+    attrs.iter().any_(|attr| "macro_escape" == attr::get_attr_name(attr))
 }
 
 // Support for item-position macro invocations, exactly the same
@@ -425,8 +425,8 @@ fn renames_to_fold(renames : @mut ~[(ast::ident,ast::Name)]) -> @ast_fold {
         fold_ident: |id,_| {
             // the individual elements are memoized... it would
             // also be possible to memoize on the whole list at once.
-            let new_ctxt = renames.foldl(id.ctxt,|ctxt,&(from,to)| {
-                new_rename(from,to,*ctxt)
+            let new_ctxt = renames.iter().fold(id.ctxt,|ctxt,&(from,to)| {
+                new_rename(from,to,ctxt)
             });
             ast::ident{name:id.name,ctxt:new_ctxt}
         },
diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs
index 1076c5d0b98..8b044bd14e1 100644
--- a/src/libsyntax/ext/pipes/liveness.rs
+++ b/src/libsyntax/ext/pipes/liveness.rs
@@ -47,13 +47,13 @@ use extra::bitv::Bitv;
 pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
     debug!("initializing colive analysis");
     let num_states = proto.num_states();
-    let mut colive = do (copy proto.states).map_to_vec |state| {
+    let mut colive: ~[~Bitv] = do (copy proto.states).iter().transform() |state| {
         let mut bv = ~Bitv::new(num_states, false);
         for state.reachable |s| {
             bv.set(s.id, true);
         }
         bv
-    };
+    }.collect();
 
     let mut i = 0;
     let mut changed = true;
@@ -61,7 +61,7 @@ pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
         changed = false;
         debug!("colive iteration %?", i);
         let mut new_colive = ~[];
-        for colive.eachi |i, this_colive| {
+        for colive.iter().enumerate().advance |(i, this_colive)| {
             let mut result = this_colive.clone();
             let this = proto.get_state_by_id(i);
             for this_colive.ones |j| {
@@ -80,7 +80,7 @@ pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
 
     // Determine if we're bounded
     let mut self_live = ~[];
-    for colive.eachi |i, bv| {
+    for colive.iter().enumerate().advance |(i, bv)| {
         if bv.get(i) {
             self_live.push(proto.get_state_by_id(i))
         }
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs
index 9adbbb7d7f3..083386fe720 100644
--- a/src/libsyntax/ext/pipes/pipec.rs
+++ b/src/libsyntax/ext/pipes/pipec.rs
@@ -333,14 +333,14 @@ impl gen_init for protocol {
             dummy_sp(),
             path(~[ext_cx.ident_of("__Buffer")],
                  dummy_sp()),
-            self.states.map_to_vec(|s| {
+            self.states.iter().transform(|s| {
                 let fty = s.to_ty(ext_cx);
                 ext_cx.field_imm(dummy_sp(),
                                  ext_cx.ident_of(s.name),
                                  quote_expr!(
                                      ::std::pipes::mk_packet::<$fty>()
                                  ))
-            }))
+            }).collect())
     }
 
     fn gen_init_bounded(&self, ext_cx: @ExtCtxt) -> @ast::expr {
@@ -354,10 +354,10 @@ impl gen_init for protocol {
         let entangle_body = ext_cx.expr_blk(
             ext_cx.blk(
                 dummy_sp(),
-                self.states.map_to_vec(
+                self.states.iter().transform(
                     |s| ext_cx.parse_stmt(
                         fmt!("data.%s.set_buffer(buffer)",
-                             s.name).to_managed())),
+                             s.name).to_managed())).collect(),
                 Some(ext_cx.parse_expr(fmt!(
                     "::std::ptr::to_mut_unsafe_ptr(&mut (data.%s))",
                     self.states[0].name).to_managed()))));
@@ -390,7 +390,7 @@ impl gen_init for protocol {
     fn gen_buffer_type(&self, cx: @ExtCtxt) -> @ast::item {
         let ext_cx = cx;
         let mut params: OptVec<ast::TyParam> = opt_vec::Empty;
-        let fields = do (copy self.states).map_to_vec |s| {
+        let fields = do (copy self.states).iter().transform |s| {
             for s.generics.ty_params.each |tp| {
                 match params.find(|tpp| tp.ident == tpp.ident) {
                   None => params.push(*tp),
@@ -411,7 +411,7 @@ impl gen_init for protocol {
                 },
                 span: dummy_sp()
             }
-        };
+        }.collect();
 
         let generics = Generics {
             lifetimes: opt_vec::Empty,
diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs
index 32714f37272..3df19ed0a76 100644
--- a/src/libsyntax/ext/pipes/proto.rs
+++ b/src/libsyntax/ext/pipes/proto.rs
@@ -146,13 +146,13 @@ pub struct protocol_ {
 impl protocol_ {
     /// Get a state.
     pub fn get_state(&self, name: &str) -> state {
-        self.states.find(|i| name == i.name).get()
+        *self.states.iter().find_(|i| name == i.name).get()
     }
 
     pub fn get_state_by_id(&self, id: uint) -> state { self.states[id] }
 
     pub fn has_state(&self, name: &str) -> bool {
-        self.states.find(|i| name == i.name).is_some()
+        self.states.iter().find_(|i| name == i.name).is_some()
     }
 
     pub fn filename(&self) -> ~str {
@@ -216,12 +216,12 @@ pub fn visit<Tproto, Tstate, Tmessage, V: visitor<Tproto, Tstate, Tmessage>>(
     proto: protocol, visitor: V) -> Tproto {
 
     // the copy keywords prevent recursive use of dvec
-    let states = do (copy proto.states).map_to_vec |&s| {
-        let messages = do (copy s.messages).map_to_vec |&m| {
+    let states: ~[Tstate] = do (copy proto.states).iter().transform |&s| {
+        let messages: ~[Tmessage] = do (copy s.messages).iter().transform |&m| {
             let message(name, span, tys, this, next) = m;
             visitor.visit_message(name, span, tys, this, next)
-        };
+        }.collect();
         visitor.visit_state(s, messages)
-    };
+    }.collect();
     visitor.visit_proto(proto, states)
 }
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 7cca7162fc8..2b65e6599f6 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -94,7 +94,7 @@ pub fn add_new_extension(cx: @ExtCtxt,
 
         let s_d = cx.parse_sess().span_diagnostic;
 
-        for lhses.eachi |i, lhs| { // try each arm's matchers
+        for lhses.iter().enumerate().advance |(i, lhs)| { // try each arm's matchers
             match *lhs {
               @matched_nonterminal(nt_matchers(ref mtcs)) => {
                 // `none` is because we're not interpolating
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index e72d9b502dc..d73c5240a1c 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -592,7 +592,7 @@ pub fn print_item(s: @ps, item: @ast::item) {
         print_generics(s, generics);
         if traits.len() != 0u {
             word(s.s, ":");
-            for traits.eachi |i, trait_| {
+            for traits.iter().enumerate().advance |(i, trait_)| {
                 nbsp(s);
                 if i != 0 {
                     word_space(s, "+");
@@ -758,7 +758,7 @@ pub fn print_tt(s: @ps, tt: &ast::token_tree) {
 
 pub fn print_tts(s: @ps, tts: &[ast::token_tree]) {
     ibox(s, 0);
-    for tts.eachi |i, tt| {
+    for tts.iter().enumerate().advance |(i, tt)| {
         if i != 0 {
             space(s.s);
         }
@@ -1229,7 +1229,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
         space(s.s);
         bopen(s);
         let len = arms.len();
-        for arms.eachi |i, arm| {
+        for arms.iter().enumerate().advance |(i, arm)| {
             space(s.s);
             cbox(s, indent_unit);
             ibox(s, 0u);