]> git.lizzy.rs Git - rust.git/commitdiff
option: remove redundant old_iter impls
authorDaniel Micay <danielmicay@gmail.com>
Mon, 10 Jun 2013 21:50:12 +0000 (17:50 -0400)
committerDaniel Micay <danielmicay@gmail.com>
Tue, 11 Jun 2013 18:06:12 +0000 (14:06 -0400)
70 files changed:
src/compiletest/procsrv.rs
src/libextra/par.rs
src/libextra/treemap.rs
src/librust/rust.rc
src/librustc/metadata/encoder.rs
src/librustc/middle/astencode.rs
src/librustc/middle/borrowck/check_loans.rs
src/librustc/middle/borrowck/gather_loans/mod.rs
src/librustc/middle/borrowck/move_data.rs
src/librustc/middle/check_const.rs
src/librustc/middle/check_match.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/kind.rs
src/librustc/middle/lint.rs
src/librustc/middle/liveness.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/moves.rs
src/librustc/middle/region.rs
src/librustc/middle/resolve.rs
src/librustc/middle/trans/_match.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/callee.rs
src/librustc/middle/trans/closure.rs
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/monomorphize.rs
src/librustc/middle/trans/reachable.rs
src/librustc/middle/trans/type_use.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/check/_match.rs
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/regionmanip.rs
src/librustc/middle/typeck/check/vtable.rs
src/librustc/middle/typeck/check/writeback.rs
src/librustc/middle/typeck/coherence.rs
src/librustc/middle/typeck/collect.rs
src/librustc/middle/typeck/infer/mod.rs
src/librustc/util/ppaux.rs
src/librustpkg/package_source.rs
src/librustpkg/rustpkg.rc
src/libstd/hashmap.rs
src/libstd/iterator.rs
src/libstd/option.rs
src/libstd/os.rs
src/libstd/run.rs
src/libstd/task/spawn.rs
src/libstd/unstable/extfmt.rs
src/libsyntax/ast_map.rs
src/libsyntax/ast_util.rs
src/libsyntax/diagnostic.rs
src/libsyntax/ext/expand.rs
src/libsyntax/print/pprust.rs
src/libsyntax/visit.rs
src/test/bench/graph500-bfs.rs
src/test/run-pass/block-arg.rs
src/test/run-pass/early-vtbl-resolution.rs
src/test/run-pass/iter-all.rs [deleted file]
src/test/run-pass/iter-any.rs [deleted file]
src/test/run-pass/iter-contains.rs [deleted file]
src/test/run-pass/iter-count.rs [deleted file]
src/test/run-pass/iter-eachi.rs [deleted file]
src/test/run-pass/iter-filter-to-vec.rs [deleted file]
src/test/run-pass/iter-flat-map-to-vec.rs [deleted file]
src/test/run-pass/iter-foldl.rs [deleted file]
src/test/run-pass/iter-map-to-vec.rs [deleted file]
src/test/run-pass/iter-min-max.rs [deleted file]
src/test/run-pass/iter-to-vec.rs [deleted file]
src/test/run-pass/test-ignore-cfg.rs

index 87188100f4c52c39d57ab24708fcdb7d268cbffa..9317858d6da4f806bb2d81a90b307ccf3273d908 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use core::os;
 use core::run;
@@ -58,7 +59,7 @@ pub fn run(lib_path: &str,
         err_fd: None
     });
 
-    for input.each |input| {
+    for input.iter().advance |input| {
         proc.input().write_str(*input);
     }
     let output = proc.finish_with_output();
index 23b7cdc09974780cc5fee860b3e272ac52e71232..05fe4ed72ee8e497fc30028e2dac4869ed894359 100644 (file)
@@ -139,8 +139,8 @@ pub fn any<A:Copy + Owned>(
     fn_factory: &fn() -> ~fn(&A) -> bool) -> bool {
     let mapped = map_slices(xs, || {
         let f = fn_factory();
-        let result: ~fn(uint, &[A]) -> bool = |_, slice| slice.iter().any(f);
+        let result: ~fn(uint, &[A]) -> bool = |_, slice| slice.iter().any_(f);
         result
     });
-    mapped.iter().any(|&x| x)
+    mapped.iter().any_(|&x| x)
 }
index 9db3d48a3b810b3def04da640dbf488ead3afa77..3f74b905f2a6f291faed10d48e3f46ddead49886 100644 (file)
@@ -427,7 +427,7 @@ fn symmetric_difference(&self, other: &TreeSet<T>,
                 b = y.next();
             }
         }
-        return b.each(|&x| f(x)) && y.advance(f);
+        b.iter().advance(|&x| f(x)) && y.advance(f)
     }
 
     /// Visit the values (in-order) representing the intersection
@@ -485,7 +485,7 @@ fn union(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
                 a = x.next();
             }
         }
-        return b.each(|&x| f(x)) && y.advance(f);
+        b.iter().advance(|&x| f(x)) && y.advance(f)
     }
 }
 
@@ -527,14 +527,14 @@ pub fn new(key: K, value: V) -> TreeNode<K, V> {
 
 fn each<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
                             f: &fn(&'r K, &'r V) -> bool) -> bool {
-    node.each(|x| each(&x.left, f) && f(&x.key, &x.value) &&
-                  each(&x.right, f))
+    node.iter().advance(|x| each(&x.left, f) && f(&x.key, &x.value) &&
+                            each(&x.right, f))
 }
 
 fn each_reverse<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
                                     f: &fn(&'r K, &'r V) -> bool) -> bool {
-    node.each(|x| each_reverse(&x.right, f) && f(&x.key, &x.value) &&
-                  each_reverse(&x.left, f))
+    node.iter().advance(|x| each_reverse(&x.right, f) && f(&x.key, &x.value) &&
+                            each_reverse(&x.left, f))
 }
 
 fn mutate_values<'r, K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>,
@@ -625,7 +625,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
     fn heir_swap<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>,
                                  child: &mut Option<~TreeNode<K, V>>) {
         // *could* be done without recursion, but it won't borrow check
-        for child.each_mut |x| {
+        for child.mut_iter().advance |x| {
             if x.right.is_some() {
                 heir_swap(node, &mut x.right);
             } else {
@@ -680,18 +680,18 @@ fn heir_swap<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>,
                 save.level -= 1;
 
                 if right_level > save.level {
-                    for save.right.each_mut |x| { x.level = save.level }
+                    for save.right.mut_iter().advance |x| { x.level = save.level }
                 }
 
                 skew(save);
 
-                for save.right.each_mut |right| {
+                for save.right.mut_iter().advance |right| {
                     skew(right);
-                    for right.right.each_mut |x| { skew(x) }
+                    for right.right.mut_iter().advance |x| { skew(x) }
                 }
 
                 split(save);
-                for save.right.each_mut |x| { split(x) }
+                for save.right.mut_iter().advance |x| { split(x) }
             }
 
             return ret;
@@ -1111,6 +1111,7 @@ fn test_each() {
 
         let mut n = 0;
         for m.each |x| {
+            println(fmt!("%?", x));
             assert_eq!(*x, n);
             n += 1
         }
index ff766417c2ace0f2293e36226d31458e6fc13624..5bc490937b615742db434dadf9579e36583368bf 100644 (file)
@@ -30,6 +30,7 @@ extern mod rusti;
 extern mod rustc;
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use core::io;
 use core::os;
@@ -242,7 +243,8 @@ pub fn main() {
     let args = os_args.tail();
 
     if !args.is_empty() {
-        for find_cmd(*args.head()).each |command| {
+        let r = find_cmd(*args.head());
+        for r.iter().advance |command| {
             let result = do_command(command, args.tail());
             match result {
                 Valid(exit_code) => unsafe { exit(exit_code.to_i32()) },
index c696aacb449806d4ff3d2a6a8851fb46a6479af4..e0061f3f95e57f0725a329c94a56ab27c992e747 100644 (file)
@@ -22,6 +22,7 @@
 use middle;
 use util::ppaux::ty_to_str;
 
+use core::iterator::IteratorUtil;
 use core::hash::HashUtil;
 use core::hashmap::HashMap;
 use core::int;
@@ -120,7 +121,7 @@ fn encode_region_param(ecx: @EncodeContext,
                        ebml_w: &mut writer::Encoder,
                        it: @ast::item) {
     let opt_rp = ecx.tcx.region_paramd_items.find(&it.id);
-    for opt_rp.each |rp| {
+    for opt_rp.iter().advance |rp| {
         ebml_w.start_tag(tag_region_param);
         rp.encode(ebml_w);
         ebml_w.end_tag();
@@ -240,7 +241,7 @@ fn encode_type(ecx: @EncodeContext,
 fn encode_transformed_self_ty(ecx: @EncodeContext,
                               ebml_w: &mut writer::Encoder,
                               opt_typ: Option<ty::t>) {
-    for opt_typ.each |&typ| {
+    for opt_typ.iter().advance |&typ| {
         ebml_w.start_tag(tag_item_method_transformed_self_ty);
         write_type(ecx, ebml_w, typ);
         ebml_w.end_tag();
@@ -956,7 +957,7 @@ fn add_to_index_(item: @item, ebml_w: &writer::Encoder,
             ebml_w.writer.write(str::to_bytes(def_to_str(method_def_id)));
             ebml_w.end_tag();
         }
-        for opt_trait.each |ast_trait_ref| {
+        for opt_trait.iter().advance |ast_trait_ref| {
             let trait_ref = ty::node_id_to_trait_ref(ecx.tcx, ast_trait_ref.ref_id);
             encode_trait_ref(ebml_w, ecx, trait_ref, tag_item_trait_ref);
         }
index 79f5b7984b6a4b35dd9ee8d784e970fe7cedfcc3..0c68251acbec2aaddeaef3d55afc0e702b46377e 100644 (file)
@@ -25,6 +25,7 @@
 use middle;
 use util::ppaux::ty_to_str;
 
+use core::iterator::IteratorUtil;
 use core::at_vec;
 use core::uint;
 use extra::ebml::reader;
@@ -826,86 +827,113 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
 
     debug!("Encoding side tables for id %d", id);
 
-    for tcx.def_map.find(&id).each |def| {
-        do ebml_w.tag(c::tag_table_def) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                (*def).encode(ebml_w)
+    {
+        let r = tcx.def_map.find(&id);
+        for r.iter().advance |def| {
+            do ebml_w.tag(c::tag_table_def) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    (*def).encode(ebml_w)
+                }
             }
         }
     }
 
-    for tcx.node_types.find(&(id as uint)).each |&ty| {
-        do ebml_w.tag(c::tag_table_node_type) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                ebml_w.emit_ty(ecx, *ty);
+    {
+        let r = tcx.node_types.find(&(id as uint));
+        for r.iter().advance |&ty| {
+            do ebml_w.tag(c::tag_table_node_type) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    ebml_w.emit_ty(ecx, *ty);
+                }
             }
         }
     }
 
-    for tcx.node_type_substs.find(&id).each |tys| {
-        do ebml_w.tag(c::tag_table_node_type_subst) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                ebml_w.emit_tys(ecx, **tys)
+    {
+        let r = tcx.node_type_substs.find(&id);
+        for r.iter().advance |tys| {
+            do ebml_w.tag(c::tag_table_node_type_subst) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    ebml_w.emit_tys(ecx, **tys)
+                }
             }
         }
     }
 
-    for tcx.freevars.find(&id).each |&fv| {
-        do ebml_w.tag(c::tag_table_freevars) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                do ebml_w.emit_from_vec(**fv) |ebml_w, fv_entry| {
-                    encode_freevar_entry(ebml_w, *fv_entry)
+    {
+        let r = tcx.freevars.find(&id);
+        for r.iter().advance |&fv| {
+            do ebml_w.tag(c::tag_table_freevars) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    do ebml_w.emit_from_vec(**fv) |ebml_w, fv_entry| {
+                        encode_freevar_entry(ebml_w, *fv_entry)
+                    }
                 }
             }
         }
     }
 
     let lid = ast::def_id { crate: ast::local_crate, node: id };
-    for tcx.tcache.find(&lid).each |&tpbt| {
-        do ebml_w.tag(c::tag_table_tcache) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                ebml_w.emit_tpbt(ecx, *tpbt);
+    {
+        let r = tcx.tcache.find(&lid);
+        for r.iter().advance |&tpbt| {
+            do ebml_w.tag(c::tag_table_tcache) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    ebml_w.emit_tpbt(ecx, *tpbt);
+                }
             }
         }
     }
 
-    for tcx.ty_param_defs.find(&id).each |&type_param_def| {
-        do ebml_w.tag(c::tag_table_param_defs) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                ebml_w.emit_type_param_def(ecx, type_param_def)
+    {
+        let r = tcx.ty_param_defs.find(&id);
+        for r.iter().advance |&type_param_def| {
+            do ebml_w.tag(c::tag_table_param_defs) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    ebml_w.emit_type_param_def(ecx, type_param_def)
+                }
             }
         }
     }
 
-    for maps.method_map.find(&id).each |&mme| {
-        do ebml_w.tag(c::tag_table_method_map) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                encode_method_map_entry(ecx, ebml_w, *mme)
+    {
+        let r = maps.method_map.find(&id);
+        for r.iter().advance |&mme| {
+            do ebml_w.tag(c::tag_table_method_map) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    encode_method_map_entry(ecx, ebml_w, *mme)
+                }
             }
         }
     }
 
-    for maps.vtable_map.find(&id).each |&dr| {
-        do ebml_w.tag(c::tag_table_vtable_map) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                encode_vtable_res(ecx, ebml_w, *dr);
+    {
+        let r = maps.vtable_map.find(&id);
+        for r.iter().advance |&dr| {
+            do ebml_w.tag(c::tag_table_vtable_map) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    encode_vtable_res(ecx, ebml_w, *dr);
+                }
             }
         }
     }
 
-    for tcx.adjustments.find(&id).each |adj| {
-        do ebml_w.tag(c::tag_table_adjustments) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                (**adj).encode(ebml_w)
+    {
+        let r = tcx.adjustments.find(&id);
+        for r.iter().advance |adj| {
+            do ebml_w.tag(c::tag_table_adjustments) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    (**adj).encode(ebml_w)
+                }
             }
         }
     }
@@ -916,12 +944,15 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
         }
     }
 
-    for maps.capture_map.find(&id).each |&cap_vars| {
-        do ebml_w.tag(c::tag_table_capture_map) |ebml_w| {
-            ebml_w.id(id);
-            do ebml_w.tag(c::tag_table_val) |ebml_w| {
-                do ebml_w.emit_from_vec(*cap_vars) |ebml_w, cap_var| {
-                    cap_var.encode(ebml_w);
+    {
+        let r = maps.capture_map.find(&id);
+        for r.iter().advance |&cap_vars| {
+            do ebml_w.tag(c::tag_table_capture_map) |ebml_w| {
+                ebml_w.id(id);
+                do ebml_w.tag(c::tag_table_val) |ebml_w| {
+                    do ebml_w.emit_from_vec(*cap_vars) |ebml_w, cap_var| {
+                        cap_var.encode(ebml_w);
+                    }
                 }
             }
         }
index 30ddab01730720fe44ba921ee90c759830fd0d94..ff57653115c6f675b24572a37a98e4114a59d284 100644 (file)
@@ -18,6 +18,7 @@
 // 4. moves do not affect things loaned out in any way
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use core::hashmap::HashSet;
 use core::uint;
@@ -581,14 +582,15 @@ pub fn analyze_move_out_from_cmt(&self, cmt: mc::cmt) -> MoveError {
         // FIXME(#4384) inadequare if/when we permit `move a.b`
 
         // check for a conflicting loan:
-        for opt_loan_path(cmt).each |&lp| {
+        let r = opt_loan_path(cmt);
+        for r.iter().advance |&lp| {
             for self.each_in_scope_restriction(cmt.id, lp) |loan, _| {
                 // Any restriction prevents moves.
                 return MoveWhileBorrowed(lp, loan.loan_path, loan.span);
             }
         }
 
-        return MoveOk;
+        MoveOk
     }
 
     pub fn check_call(&mut self,
@@ -700,9 +702,9 @@ fn check_loans_in_expr<'a>(expr: @ast::expr,
           if !this.move_data.is_assignee(expr.id) {
               let cmt = this.bccx.cat_expr_unadjusted(expr);
               debug!("path cmt=%s", cmt.repr(this.tcx()));
-              for opt_loan_path(cmt).each |&lp| {
-                  this.check_if_path_is_moved(expr.id, expr.span,
-                                              MovedInUse, lp);
+              let r = opt_loan_path(cmt);
+              for r.iter().advance |&lp| {
+                  this.check_if_path_is_moved(expr.id, expr.span, MovedInUse, lp);
               }
           }
       }
index 805d68214c33cf3ec70c7b864f82c61a94dfe911..fa7c3fb52f43a1e35c56a4c669666e1ea04c899b 100644 (file)
@@ -17,6 +17,7 @@
 // sure that all of these loans are honored.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use middle::borrowck::*;
 use middle::borrowck::move_data::MoveData;
@@ -176,13 +177,19 @@ fn gather_loans_in_expr(ex: @ast::expr,
 
     this.id_range.add(ex.id);
 
-    for ex.get_callee_id().each |callee_id| {
-        this.id_range.add(*callee_id);
+    {
+        let r = ex.get_callee_id();
+        for r.iter().advance |callee_id| {
+            this.id_range.add(*callee_id);
+        }
     }
 
     // If this expression is borrowed, have to ensure it remains valid:
-    for tcx.adjustments.find(&ex.id).each |&adjustments| {
-        this.guarantee_adjustments(ex, *adjustments);
+    {
+        let r = tcx.adjustments.find(&ex.id);
+        for r.iter().advance |&adjustments| {
+            this.guarantee_adjustments(ex, *adjustments);
+        }
     }
 
     // If this expression is a move, gather it:
index 2443c19ac97c5ef320e91909012ae1dc3ecca0c5..6b16bb5a3c35870228a38816e94db072387267b7 100644 (file)
@@ -16,6 +16,7 @@
 */
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use core::hashmap::{HashMap, HashSet};
 use core::uint;
@@ -516,7 +517,7 @@ pub fn each_move_of(&self,
                 loop;
             }
 
-            for opt_loan_path_index.each |&loan_path_index| {
+            for opt_loan_path_index.iter().advance |&loan_path_index| {
                 for self.move_data.each_base_path(moved_path) |p| {
                     if p == loan_path_index {
                         // Scenario 3: some extension of `loan_path`
index 0cffc9c52c22b3c4c189c0a53c190c9618781b64..b048a58b840096decf4ee9f729bd3738849b4c52 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use core::iterator::IteratorUtil;
 use core::prelude::*;
 
 use driver::session::Session;
@@ -49,7 +50,7 @@ pub fn check_item(sess: Session,
       }
       item_enum(ref enum_definition, _) => {
         for (*enum_definition).variants.each |var| {
-            for var.node.disr_expr.each |ex| {
+            for var.node.disr_expr.iter().advance |ex| {
                 (v.visit_expr)(*ex, true, v);
             }
         }
index c95ff49e53cd50b5073e3bacacb46f8d2f3c3093..c352771733934146b3e1322476ea967b8fa2907c 100644 (file)
@@ -363,7 +363,8 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
       ty::ty_enum(eid, _) => {
         let mut found = ~[];
         for m.each |r| {
-            for pat_ctor_id(cx, r[0]).each |id| {
+            let r = pat_ctor_id(cx, r[0]);
+            for r.iter().advance |id| {
                 if !vec::contains(found, id) {
                     found.push(/*bad*/copy *id);
                 }
index c528bad0b070b95d4f2116f54013443ca654af00..530f16609845373fe84a3ec58a0b0078d6b37a9d 100644 (file)
@@ -794,7 +794,7 @@ fn walk_opt_expr(&mut self,
                      opt_expr: Option<@ast::expr>,
                      in_out: &mut [uint],
                      loop_scopes: &mut ~[LoopScope]) {
-        for opt_expr.each |&expr| {
+        for opt_expr.iter().advance |&expr| {
             self.walk_expr(expr, in_out, loop_scopes);
         }
     }
index f1938129b06015b806929666eafd46d1283567d6..0c1862d9c48b8b8412dd0a81c4fbaae8fd67325f 100644 (file)
@@ -245,32 +245,35 @@ pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
         Some(callee_id) => callee_id,
         None => e.id,
     };
-    for cx.tcx.node_type_substs.find(&type_parameter_id).each |ts| {
-        let type_param_defs = match e.node {
-          expr_path(_) => {
-            let did = ast_util::def_id_of_def(cx.tcx.def_map.get_copy(&e.id));
-            ty::lookup_item_type(cx.tcx, did).generics.type_param_defs
-          }
-          _ => {
-            // Type substitutions should only occur on paths and
-            // method calls, so this needs to be a method call.
-
-            // Even though the callee_id may have been the id with
-            // node_type_substs, e.id is correct here.
-            ty::method_call_type_param_defs(cx.tcx, cx.method_map, e.id).expect(
-                "non path/method call expr has type substs??")
-          }
-        };
-        if ts.len() != type_param_defs.len() {
-            // Fail earlier to make debugging easier
-            fail!("internal error: in kind::check_expr, length \
-                  mismatch between actual and declared bounds: actual = \
-                  %s, declared = %s",
-                  ts.repr(cx.tcx),
-                  type_param_defs.repr(cx.tcx));
-        }
-        for ts.iter().zip(type_param_defs.iter()).advance |(&ty, type_param_def)| {
-            check_bounds(cx, type_parameter_id, e.span, ty, type_param_def)
+    {
+        let r = cx.tcx.node_type_substs.find(&type_parameter_id);
+        for r.iter().advance |ts| {
+            let type_param_defs = match e.node {
+              expr_path(_) => {
+                let did = ast_util::def_id_of_def(cx.tcx.def_map.get_copy(&e.id));
+                ty::lookup_item_type(cx.tcx, did).generics.type_param_defs
+              }
+              _ => {
+                // Type substitutions should only occur on paths and
+                // method calls, so this needs to be a method call.
+
+                // Even though the callee_id may have been the id with
+                // node_type_substs, e.id is correct here.
+                ty::method_call_type_param_defs(cx.tcx, cx.method_map, e.id).expect(
+                    "non path/method call expr has type substs??")
+              }
+            };
+            if ts.len() != type_param_defs.len() {
+                // Fail earlier to make debugging easier
+                fail!("internal error: in kind::check_expr, length \
+                      mismatch between actual and declared bounds: actual = \
+                      %s, declared = %s",
+                      ts.repr(cx.tcx),
+                      type_param_defs.repr(cx.tcx));
+            }
+            for ts.iter().zip(type_param_defs.iter()).advance |(&ty, type_param_def)| {
+                check_bounds(cx, type_parameter_id, e.span, ty, type_param_def)
+            }
         }
     }
 
@@ -306,14 +309,15 @@ pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
 fn check_ty(aty: @Ty, cx: Context, v: visit::vt<Context>) {
     match aty.node {
       ty_path(_, id) => {
-        for cx.tcx.node_type_substs.find(&id).each |ts| {
-            let did = ast_util::def_id_of_def(cx.tcx.def_map.get_copy(&id));
-            let type_param_defs =
-                ty::lookup_item_type(cx.tcx, did).generics.type_param_defs;
-            for ts.iter().zip(type_param_defs.iter()).advance |(&ty, type_param_def)| {
-                check_bounds(cx, aty.id, aty.span, ty, type_param_def)
-            }
-        }
+          let r = cx.tcx.node_type_substs.find(&id);
+          for r.iter().advance |ts| {
+              let did = ast_util::def_id_of_def(cx.tcx.def_map.get_copy(&id));
+              let type_param_defs =
+                  ty::lookup_item_type(cx.tcx, did).generics.type_param_defs;
+              for ts.iter().zip(type_param_defs.iter()).advance |(&ty, type_param_def)| {
+                  check_bounds(cx, aty.id, aty.span, ty, type_param_def)
+              }
+          }
       }
       _ => {}
     }
index 92147bf4e0f7237ed2a4cb163148fd70c1cae610..007970067b331046f1194f81f5d12d535ee4ffc3 100644 (file)
@@ -15,6 +15,7 @@
 use middle::pat_util;
 use util::ppaux::{ty_to_str};
 
+use core::iterator::IteratorUtil;
 use core::char;
 use core::cmp;
 use core::hashmap::HashMap;
@@ -388,7 +389,7 @@ fn span_lint(&self, lint: lint, span: span, msg: &str) {
             allow => fail!(),
         }
 
-        for note.each |&span| {
+        for note.iter().advance |&span| {
             self.tcx.sess.span_note(span, "lint level defined here");
         }
     }
index 8a9a67db8027154e16e75f191b4de3a16c378fc3..0fceb2261ee6ee806a7ea05179e691f103134e74 100644 (file)
 use core::cast::transmute;
 use core::hashmap::HashMap;
 use core::io;
-use core::old_iter;
 use core::to_str;
 use core::uint;
 use core::vec;
@@ -987,8 +986,8 @@ pub fn propagate_through_opt_expr(&self,
                                       opt_expr: Option<@expr>,
                                       succ: LiveNode)
                                       -> LiveNode {
-        do old_iter::foldl(&opt_expr, succ) |succ, expr| {
-            self.propagate_through_expr(*expr, *succ)
+        do opt_expr.iter().fold(succ) |succ, expr| {
+            self.propagate_through_expr(*expr, succ)
         }
     }
 
@@ -1624,7 +1623,8 @@ pub fn warn_about_unused(&self,
                              var: Variable)
                              -> bool {
         if !self.used_on_entry(ln, var) {
-            for self.should_warn(var).each |name| {
+            let r = self.should_warn(var);
+            for r.iter().advance |name| {
 
                 // annoying: for parameters in funcs like `fn(x: int)
                 // {ret}`, there is only one node, so asking about
@@ -1644,9 +1644,10 @@ pub fn warn_about_unused(&self,
                         fmt!("unused variable: `%s`", **name));
                 }
             }
-            return true;
+            true
+        } else {
+            false
         }
-        return false;
     }
 
     pub fn warn_about_dead_assign(&self,
@@ -1655,7 +1656,8 @@ pub fn warn_about_dead_assign(&self,
                                   ln: LiveNode,
                                   var: Variable) {
         if self.live_on_exit(ln, var).is_none() {
-            for self.should_warn(var).each |name| {
+            let r = self.should_warn(var);
+            for r.iter().advance |name| {
                 self.tcx.sess.add_lint(dead_assignment, id, sp,
                     fmt!("value assigned to `%s` is never read", **name));
             }
index f54e1e623ecd961008d818766136f4fe1fc1ad38..2802a92a1f99a0480fa485e3500b9b37877a289b 100644 (file)
@@ -47,6 +47,7 @@
  */
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use middle::ty;
 use middle::typeck;
@@ -948,7 +949,7 @@ pub fn cat_pattern(&self,
               for before.each |&before_pat| {
                   self.cat_pattern(elt_cmt, before_pat, op);
               }
-              for slice.each |&slice_pat| {
+              for slice.iter().advance |&slice_pat| {
                   let slice_ty = self.pat_ty(slice_pat);
                   let slice_cmt = self.cat_rvalue(pat, slice_ty);
                   self.cat_pattern(slice_cmt, slice_pat, op);
index caa18b2834fe52c12b616968b91f041ed68333ac..ccdfed6f126d7bee1215d166218599eaf131abe3 100644 (file)
@@ -127,6 +127,7 @@ struct Foo { a: int, b: ~int }
 */
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use middle::pat_util::{pat_bindings};
 use middle::freevars;
@@ -267,7 +268,7 @@ pub fn consume_block(&self, blk: &blk, visitor: vt<VisitContext>) {
             (visitor.visit_stmt)(*stmt, *self, visitor);
         }
 
-        for blk.node.expr.each |tail_expr| {
+        for blk.node.expr.iter().advance |tail_expr| {
             self.consume_expr(*tail_expr, visitor);
         }
     }
@@ -302,7 +303,8 @@ pub fn use_expr(&self,
                 match comp_mode {
                     Move => {
                         let def = self.tcx.def_map.get_copy(&expr.id);
-                        for moved_variable_node_id_from_def(def).each |&id| {
+                        let r = moved_variable_node_id_from_def(def);
+                        for r.iter().advance |&id| {
                             self.move_maps.moved_variables_set.insert(id);
                         }
                     }
@@ -350,7 +352,7 @@ pub fn use_expr(&self,
                     self.consume_expr(field.node.expr, visitor);
                 }
 
-                for opt_with.each |with_expr| {
+                for opt_with.iter().advance |with_expr| {
                     // If there are any fields whose type is move-by-default,
                     // then `with` is consumed, otherwise it is only read
                     let with_ty = ty::expr_ty(self.tcx, *with_expr);
@@ -389,7 +391,7 @@ pub fn use_expr(&self,
             expr_if(cond_expr, ref then_blk, opt_else_expr) => {
                 self.consume_expr(cond_expr, visitor);
                 self.consume_block(then_blk, visitor);
-                for opt_else_expr.each |else_expr| {
+                for opt_else_expr.iter().advance |else_expr| {
                     self.consume_expr(*else_expr, visitor);
                 }
             }
@@ -466,7 +468,7 @@ pub fn use_expr(&self,
             }
 
             expr_ret(ref opt_expr) => {
-                for opt_expr.each |expr| {
+                for opt_expr.iter().advance |expr| {
                     self.consume_expr(*expr, visitor);
                 }
             }
@@ -541,11 +543,11 @@ pub fn use_overloaded_operator(&self,
     }
 
     pub fn consume_arm(&self, arm: &arm, visitor: vt<VisitContext>) {
-        for arm.pats.each |pat| {
+        for arm.pats.iter().advance |pat| {
             self.use_pat(*pat);
         }
 
-        for arm.guard.each |guard| {
+        for arm.guard.iter().advance |guard| {
             self.consume_expr(*guard, visitor);
         }
 
index 5ccb38b960d5883ec9af7d2673b7cbc4dcf9e414..8a526efbc3a880e5095d55f90881a30b47323ef1 100644 (file)
@@ -26,6 +26,7 @@
 use middle::ty::{rv_contravariant, FreeRegion};
 use middle::ty;
 
+use core::iterator::IteratorUtil;
 use core::hashmap::{HashMap, HashSet};
 use syntax::ast_map;
 use syntax::codemap::span;
@@ -329,7 +330,7 @@ pub fn parent_id(cx: Context, span: span) -> ast::node_id {
 pub fn parent_to_expr(cx: Context, child_id: ast::node_id, sp: span) {
     debug!("region::parent_to_expr(span=%?)",
            cx.sess.codemap.span_to_str(sp));
-    for cx.parent.each |parent_id| {
+    for cx.parent.iter().advance |parent_id| {
         cx.region_maps.record_parent(child_id, *parent_id);
     }
 }
index 97b0d61499bf4afd4dd7e8cd046761c9f2b1d851..7c9877a838ad77c790d9074aa94eea01167aadd0 100644 (file)
@@ -1036,11 +1036,14 @@ pub fn add_child(@mut self,
                         fmt!("duplicate definition of %s `%s`",
                              namespace_to_str(ns),
                              *self.session.str_of(name)));
-                    for child.span_for_namespace(ns).each |sp| {
-                        self.session.span_note(*sp,
-                             fmt!("first definition of %s %s here:",
-                                  namespace_to_str(ns),
-                                  *self.session.str_of(name)));
+                    {
+                        let r = child.span_for_namespace(ns);
+                        for r.iter().advance |sp| {
+                            self.session.span_note(*sp,
+                                 fmt!("first definition of %s %s here:",
+                                      namespace_to_str(ns),
+                                      *self.session.str_of(name)));
+                        }
                     }
                 }
                 return (child, new_parent);
@@ -3490,7 +3493,7 @@ pub fn resolve_item(@mut self, item: @item, visitor: ResolveVisitor) {
             // then resolve the ty params
             item_enum(ref enum_def, ref generics) => {
                 for (*enum_def).variants.each() |variant| {
-                    for variant.node.disr_expr.each |dis_expr| {
+                    for variant.node.disr_expr.iter().advance |dis_expr| {
                         // resolve the discriminator expr
                         // as a constant
                         self.with_constant_rib(|| {
@@ -3907,8 +3910,11 @@ pub fn resolve_implementation(@mut self,
 
                     // Record the current set of trait references.
                     let mut new_trait_refs = ~[];
-                    for self.def_map.find(&trait_reference.ref_id).each |&def| {
-                        new_trait_refs.push(def_id_of_def(*def));
+                    {
+                        let r = self.def_map.find(&trait_reference.ref_id);
+                        for r.iter().advance |&def| {
+                            new_trait_refs.push(def_id_of_def(*def));
+                        }
                     }
                     original_trait_refs = Some(util::replace(
                         &mut self.current_trait_refs,
index 49db0ee7bd30af73891c106678c270dbc1b0b801..e3e431aae590295c207d657f2acf3b3b2d172e96 100644 (file)
@@ -799,7 +799,7 @@ pub fn enter_region<'r>(bcx: block,
 pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] {
     let ccx = bcx.ccx();
     fn add_to_set(tcx: ty::ctxt, set: &mut ~[Opt], val: Opt) {
-        if set.iter().any(|l| opt_eq(tcx, l, &val)) {return;}
+        if set.iter().any_(|l| opt_eq(tcx, l, &val)) {return;}
         set.push(val);
     }
 
@@ -966,7 +966,7 @@ pub fn collect_record_or_struct_fields(bcx: block,
     fn extend(idents: &mut ~[ast::ident], field_pats: &[ast::field_pat]) {
         for field_pats.each |field_pat| {
             let field_ident = field_pat.ident;
-            if !idents.iter().any(|x| *x == field_ident) {
+            if !idents.iter().any_(|x| *x == field_ident) {
                 idents.push(field_ident);
             }
         }
@@ -977,7 +977,7 @@ pub fn pats_require_rooting(bcx: block,
                             m: &[@Match],
                             col: uint)
                          -> bool {
-    do m.iter().any |br| {
+    do m.iter().any_ |br| {
         let pat_id = br.pats[col].id;
         let key = root_map_key {id: pat_id, derefs: 0u };
         bcx.ccx().maps.root_map.contains_key(&key)
@@ -1006,7 +1006,7 @@ pub fn root_pats_as_necessary(mut bcx: block,
 // matches may be wildcards like _ or identifiers).
 macro_rules! any_pat (
     ($m:expr, $pattern:pat) => (
-        do ($m).iter().any |br| {
+        do ($m).iter().any_ |br| {
             match br.pats[col].node {
                 $pattern => true,
                 _ => false
@@ -1032,7 +1032,7 @@ pub fn any_tup_pat(m: &[@Match], col: uint) -> bool {
 }
 
 pub fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool {
-    do m.iter().any |br| {
+    do m.iter().any_ |br| {
         let pat = br.pats[col];
         match pat.node {
             ast::pat_enum(_, Some(_)) => {
@@ -1427,7 +1427,7 @@ pub fn compile_submatch(bcx: block,
             var(_, repr) => {
                 let (the_kind, val_opt) = adt::trans_switch(bcx, repr, val);
                 kind = the_kind;
-                for val_opt.each |&tval| { test_val = tval; }
+                for val_opt.iter().advance |&tval| { test_val = tval; }
             }
             lit(_) => {
                 let pty = node_id_type(bcx, pat_id);
@@ -1792,7 +1792,7 @@ pub fn bind_irrefutable_pat(bcx: block,
                 }
             }
 
-            for inner.each |inner_pat| {
+            for inner.iter().advance |inner_pat| {
                 bcx = bind_irrefutable_pat(
                     bcx, *inner_pat, val, true, binding_mode);
             }
@@ -1808,7 +1808,7 @@ pub fn bind_irrefutable_pat(bcx: block,
                                                     repr,
                                                     vinfo.disr_val,
                                                     val);
-                    for sub_pats.each |sub_pat| {
+                    for sub_pats.iter().advance |sub_pat| {
                         for args.vals.eachi |i, argval| {
                             bcx = bind_irrefutable_pat(bcx,
                                                        sub_pat[i],
index 8e015d9a677e151ab4198d4a10065d75374cc8b6..332899955631deef6126d5d7ea0977af9e7f8216 100644 (file)
@@ -1194,7 +1194,7 @@ pub fn new_block(cx: fn_ctxt, parent: Option<block>, kind: block_kind,
                            is_lpad,
                            opt_node_info,
                            cx);
-        for parent.each |cx| {
+        for parent.iter().advance |cx| {
             if cx.unreachable { Unreachable(bcx); }
         };
         bcx
@@ -1313,10 +1313,12 @@ pub fn cleanup_and_leave(bcx: block,
             block_scope(inf) if !inf.empty_cleanups() => {
                 let (sub_cx, inf_cleanups) = {
                     let inf = &mut *inf; // FIXME(#5074) workaround stage0
-                    for vec::find((*inf).cleanup_paths,
-                                  |cp| cp.target == leave).each |cp| {
-                        Br(bcx, cp.dest);
-                        return;
+                    {
+                        let r = vec::find((*inf).cleanup_paths, |cp| cp.target == leave);
+                        for r.iter().advance |cp| {
+                            Br(bcx, cp.dest);
+                            return;
+                        }
                     }
                     let sub_cx = sub_block(bcx, "cleanup");
                     Br(bcx, sub_cx.llbb);
@@ -1422,7 +1424,7 @@ pub fn alloc_local(cx: block, local: @ast::local) -> block {
     };
     let val = alloc_ty(cx, t);
     if cx.sess().opts.debuginfo {
-        for simple_name.each |name| {
+        for simple_name.iter().advance |name| {
             str::as_c_str(*cx.ccx().sess.str_of(*name), |buf| {
                 unsafe {
                     llvm::LLVMSetValueName(val, buf)
@@ -1597,7 +1599,7 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
                         param_substs: Option<@param_substs>,
                         sp: Option<span>)
                      -> fn_ctxt {
-    for param_substs.each |p| { p.validate(); }
+    for param_substs.iter().advance |p| { p.validate(); }
 
     debug!("new_fn_ctxt_w_id(path=%s, id=%?, impl_id=%?, \
             param_substs=%s)",
index 767b02d13e2efffab6fe4535c339cd40b83cf02e..840bad92b198696d54385b59936fa9fffb22e305 100644 (file)
@@ -17,6 +17,7 @@
 // closure.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use back::abi;
 use driver::session;
@@ -582,9 +583,12 @@ pub fn trans_call_inner(in_cx: block,
         } else if ret_in_loop {
             let ret_flag_result = bool_to_i1(bcx, Load(bcx, ret_flag.get()));
             bcx = do with_cond(bcx, ret_flag_result) |bcx| {
-                for (copy bcx.fcx.loop_ret).each |&(flagptr, _)| {
-                    Store(bcx, C_bool(true), flagptr);
-                    Store(bcx, C_bool(false), bcx.fcx.llretptr.get());
+                {
+                    let r = (copy bcx.fcx.loop_ret);
+                    for r.iter().advance |&(flagptr, _)| {
+                        Store(bcx, C_bool(true), flagptr);
+                        Store(bcx, C_bool(false), bcx.fcx.llretptr.get());
+                    }
                 }
                 base::cleanup_and_leave(bcx, None, Some(bcx.fcx.llreturn));
                 Unreachable(bcx);
index 27d962d6cc7f6f1a10b9b245c2d2ff14fafc1ea0..d5d018c054355f932bdcbadb91400edb3def261a 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use back::abi;
 use back::link::{mangle_internal_name_by_path_and_seq};
@@ -286,7 +287,7 @@ pub fn build_closure(bcx0: block,
 
     // If this is a `for` loop body, add two special environment
     // variables:
-    for include_ret_handle.each |flagptr| {
+    for include_ret_handle.iter().advance |flagptr| {
         // Flag indicating we have returned (a by-ref bool):
         let flag_datum = Datum {val: *flagptr, ty: ty::mk_bool(),
                                 mode: ByRef(ZeroMem)};
index b29972f039b1936a564209c2fdfca257a8d5d915..d0fddf6100fd8adfa9eeaa96820fe5f0f7eab01e 100644 (file)
@@ -11,6 +11,7 @@
 //! Code that is useful in various trans modules.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use back::{abi, upcall};
 use driver::session;
@@ -253,7 +254,7 @@ pub struct param_substs {
 impl param_substs {
     pub fn validate(&self) {
         for self.tys.each |t| { assert!(!ty::type_needs_infer(*t)); }
-        for self.self_ty.each |t| { assert!(!ty::type_needs_infer(*t)); }
+        for self.self_ty.iter().advance |t| { assert!(!ty::type_needs_infer(*t)); }
     }
 }
 
@@ -553,7 +554,7 @@ pub fn revoke_clean(cx: block, val: ValueRef) {
                 clean_temp(v, _, _) if v == val => true,
                 _ => false
             });
-        for cleanup_pos.each |i| {
+        for cleanup_pos.iter().advance |i| {
             scope_info.cleanups =
                 vec::append(vec::slice(scope_info.cleanups, 0u, *i).to_vec(),
                             vec::slice(scope_info.cleanups,
index 65afafcd60d8f8dddc806bda709016a6f3c8ae18..5b286a78311985d067c98b2f83258f2ac8df8010 100644 (file)
 use util::common::indenter;
 use util::ppaux::Repr;
 
+use core::iterator::IteratorUtil;
 use core::cast::transmute;
 use core::hashmap::HashMap;
 use core::vec;
@@ -1223,7 +1224,7 @@ fn trans_adt(bcx: block, repr: &adt::Repr, discr: int,
             for fields.each |&(_i, e)| {
                 bcx = trans_into(bcx, e, Ignore);
             }
-            for optbase.each |sbi| {
+            for optbase.iter().advance |sbi| {
                 bcx = trans_into(bcx, sbi.expr, Ignore);
             }
             return bcx;
@@ -1239,11 +1240,11 @@ fn trans_adt(bcx: block, repr: &adt::Repr, discr: int,
         add_clean_temp_mem(bcx, dest, e_ty);
         temp_cleanups.push(dest);
     }
-    for optbase.each |base| {
+    for optbase.iter().advance |base| {
         // FIXME #6573: is it sound to use the destination's repr on the base?
         // And, would it ever be reasonable to be here with discr != 0?
         let base_datum = unpack_datum!(bcx, trans_to_datum(bcx, base.expr));
-        for base.fields.each |&(i, t)| {
+        for base.fields.iter().advance |&(i, t)| {
             let datum = do base_datum.get_element(bcx, t, ZeroMem) |srcval| {
                 adt::trans_field_ptr(bcx, repr, srcval, discr, i)
             };
index 169cd294b43c4324d837e0d7b889c74942f22cd7..866daabff339331a66977f58f04ada3d235ee247 100644 (file)
@@ -76,7 +76,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
     let param_uses = type_use::type_uses_for(ccx, fn_id, substs.len());
     let hash_id = make_mono_id(ccx, fn_id, substs, vtables, impl_did_opt,
                                Some(param_uses));
-    if hash_id.params.iter().any(
+    if hash_id.params.iter().any_(
                 |p| match *p { mono_precise(_, _) => false, _ => true }) {
         must_cast = true;
     }
index 237ba1f49bbc590c377df3fc95c4abc50c576f35..74c86354244f22d40ae0d8fbc13b60c3b0110f51 100644 (file)
@@ -16,6 +16,7 @@
 // reachable as well.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use middle::resolve;
 use middle::ty;
@@ -136,7 +137,7 @@ fn traverse_public_item(cx: @mut ctx, item: @item) {
         }
       }
       item_struct(ref struct_def, _) => {
-        for struct_def.ctor_id.each |&ctor_id| {
+        for struct_def.ctor_id.iter().advance |&ctor_id| {
             let cx = &mut *cx; // FIXME(#6269) reborrow @mut to &mut
             cx.rmap.insert(ctor_id);
         }
index b1b1b5212af6701f5d1ae14946b7ae33111af2e7..e533bfaa980214a8156066ebb89005d7b390c104 100644 (file)
@@ -242,19 +242,22 @@ pub fn node_type_needs(cx: Context, use_: uint, id: node_id) {
 
 pub fn mark_for_method_call(cx: Context, e_id: node_id, callee_id: node_id) {
     let mut opt_static_did = None;
-    for cx.ccx.maps.method_map.find(&e_id).each |mth| {
-        match mth.origin {
-          typeck::method_static(did) => {
-              opt_static_did = Some(did);
-          }
-          typeck::method_param(typeck::method_param {
-              param_num: param,
-              _
-          }) => {
-            cx.uses[param] |= use_tydesc;
-          }
-          typeck::method_trait(*) | typeck::method_self(*)
-              | typeck::method_super(*) => (),
+    {
+        let r = cx.ccx.maps.method_map.find(&e_id);
+        for r.iter().advance |mth| {
+            match mth.origin {
+              typeck::method_static(did) => {
+                  opt_static_did = Some(did);
+              }
+              typeck::method_param(typeck::method_param {
+                  param_num: param,
+                  _
+              }) => {
+                cx.uses[param] |= use_tydesc;
+              }
+              typeck::method_trait(*) | typeck::method_self(*)
+                  | typeck::method_super(*) => (),
+            }
         }
     }
 
@@ -262,11 +265,14 @@ pub fn mark_for_method_call(cx: Context, e_id: node_id, callee_id: node_id) {
     // above because the recursive call to `type_needs` can trigger
     // inlining and hence can cause `method_map` and
     // `node_type_substs` to be modified.
-    for opt_static_did.each |&did| {
-        for cx.ccx.tcx.node_type_substs.find_copy(&callee_id).each |ts| {
-            let type_uses = type_uses_for(cx.ccx, did, ts.len());
-            for type_uses.iter().zip(ts.iter()).advance |(uses, subst)| {
-                type_needs(cx, *uses, *subst)
+    for opt_static_did.iter().advance |&did| {
+        {
+            let r = cx.ccx.tcx.node_type_substs.find_copy(&callee_id);
+            for r.iter().advance |ts| {
+                let type_uses = type_uses_for(cx.ccx, did, ts.len());
+                for type_uses.iter().zip(ts.iter()).advance |(uses, subst)| {
+                    type_needs(cx, *uses, *subst)
+                }
             }
         }
     }
@@ -300,7 +306,7 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
       }
       expr_path(_) | expr_self => {
         let opt_ts = cx.ccx.tcx.node_type_substs.find_copy(&e.id);
-        for opt_ts.each |ts| {
+        for opt_ts.iter().advance |ts| {
             let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get_copy(&e.id));
             let uses_for_ts = type_uses_for(cx.ccx, id, ts.len());
             for uses_for_ts.iter().zip(ts.iter()).advance |(uses, subst)| {
@@ -390,7 +396,7 @@ pub fn handle_body(cx: Context, body: &blk) {
         },
         visit_block: |b, cx, v| {
             visit::visit_block(b, cx, v);
-            for b.node.expr.each |e| {
+            for b.node.expr.iter().advance |e| {
                 node_type_needs(cx, use_repr, e.id);
             }
         },
index 267eccbc3978706a1799e705e5c88d62c32ce495..ba446d6016c6c9e16270533f323d0ae328d39922 100644 (file)
@@ -1017,7 +1017,7 @@ fn rflags(r: Region) -> uint {
     fn sflags(substs: &substs) -> uint {
         let mut f = 0u;
         for substs.tps.each |tt| { f |= get(*tt).flags; }
-        for substs.self_r.each |r| { f |= rflags(*r) }
+        for substs.self_r.iter().advance |r| { f |= rflags(*r) }
         return f;
     }
     match &st {
@@ -1560,8 +1560,8 @@ pub fn type_needs_subst(ty: t) -> bool {
 }
 
 pub fn trait_ref_contains_error(tref: &ty::TraitRef) -> bool {
-    tref.substs.self_ty.any(|&t| type_is_error(t)) ||
-        tref.substs.tps.any(|&t| type_is_error(t))
+    tref.substs.self_ty.iter().any_(|&t| type_is_error(t)) ||
+        tref.substs.tps.iter().any_(|&t| type_is_error(t))
 }
 
 pub fn type_is_ty_var(ty: t) -> bool {
@@ -2357,7 +2357,7 @@ fn subtypes_require(cx: ctxt, seen: &mut ~[def_id],
             ty_struct(did, ref substs) => {
                 seen.push(did);
                 let fields = struct_fields(cx, did, substs);
-                let r = fields.iter().any(|f| type_requires(cx, seen, r_ty, f.mt.ty));
+                let r = fields.iter().any_(|f| type_requires(cx, seen, r_ty, f.mt.ty));
                 seen.pop();
                 r
             }
@@ -2374,7 +2374,7 @@ fn subtypes_require(cx: ctxt, seen: &mut ~[def_id],
                 seen.push(did);
                 let vs = enum_variants(cx, did);
                 let r = !vs.is_empty() && do vs.iter().all |variant| {
-                    do variant.args.iter().any |aty| {
+                    do variant.args.iter().any_ |aty| {
                         let sty = subst(cx, substs, *aty);
                         type_requires(cx, seen, r_ty, sty)
                     }
index 13f41c06e183921d089ff48d959663dd6d1ab243..bf4f30fb02e3934a2df6415f4fb23842a7bcb6f9 100644 (file)
@@ -231,7 +231,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
         }
 
         if !error_happened {
-            for subpats.each |pats| {
+            for subpats.iter().advance |pats| {
                 for pats.iter().zip(arg_types.iter()).advance |(subpat, arg_ty)| {
                     check_pat(pcx, *subpat, *arg_ty);
                 }
@@ -248,7 +248,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
     }
 
     if error_happened {
-        for subpats.each |pats| {
+        for subpats.iter().advance |pats| {
             for pats.each |pat| {
                 check_pat(pcx, *pat, ty::mk_err());
             }
@@ -569,7 +569,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
               for before.each |&elt| {
                   check_pat(pcx, elt, ty::mk_err());
               }
-              for slice.each |&elt| {
+              for slice.iter().advance |&elt| {
                   check_pat(pcx, elt, ty::mk_err());
               }
               for after.each |&elt| {
index 9b8393a7464bf17c72b93a043589bac1935e38b0..19acadfc572e0c0a164003bb429d8f1d1f84f343 100644 (file)
@@ -332,14 +332,14 @@ pub fn push_extension_candidates(&self, self_ty: ty::t) {
         // candidates.
         let trait_map: &mut resolve::TraitMap = &mut self.fcx.ccx.trait_map;
         let opt_applicable_traits = trait_map.find(&self.expr.id);
-        for opt_applicable_traits.each |applicable_traits| {
+        for opt_applicable_traits.iter().advance |applicable_traits| {
             for applicable_traits.each |trait_did| {
                 let coherence_info = self.fcx.ccx.coherence_info;
 
                 // Look for explicit implementations.
                 let opt_impl_infos =
                     coherence_info.extension_methods.find(trait_did);
-                for opt_impl_infos.each |impl_infos| {
+                for opt_impl_infos.iter().advance |impl_infos| {
                     for impl_infos.each |impl_info| {
                         self.push_candidates_from_impl(
                             self.extension_candidates, *impl_info);
@@ -536,7 +536,7 @@ struct MethodInfo {
     pub fn push_inherent_impl_candidates_for_type(&self, did: def_id) {
         let opt_impl_infos =
             self.fcx.ccx.coherence_info.inherent_methods.find(&did);
-        for opt_impl_infos.each |impl_infos| {
+        for opt_impl_infos.iter().advance |impl_infos| {
             for impl_infos.each |impl_info| {
                 self.push_candidates_from_impl(
                     self.inherent_candidates, *impl_info);
index b12b1499759f9ca5a9fe37f39e6b1ebf0041b98e..a75c1decd0db2d030e1bcc990cb59ec3e4ac36ca 100644 (file)
@@ -410,7 +410,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
       None => ()
     }
 
-    for opt_self_info.each |self_info| {
+    for opt_self_info.iter().advance |self_info| {
         fcx.write_ty(self_info.self_id, self_info.self_ty);
     }
     for decl.inputs.iter().zip(arg_tys.iter()).advance |(input, arg)| {
@@ -442,7 +442,7 @@ fn gather_locals(fcx: @mut FnCtxt,
         };
 
         // Add the self parameter
-        for opt_self_info.each |self_info| {
+        for opt_self_info.iter().advance |self_info| {
             assign(self_info.self_id, Some(self_info.self_ty));
             debug!("self is assigned to %s",
                    fcx.infcx().ty_to_str(
@@ -3092,7 +3092,7 @@ fn do_check(ccx: @mut CrateCtxt,
                 variants: &mut ~[ty::VariantInfo]) {
         let rty = ty::node_id_to_type(ccx.tcx, id);
         for vs.each |v| {
-            for v.node.disr_expr.each |e_ref| {
+            for v.node.disr_expr.iter().advance |e_ref| {
                 let e = *e_ref;
                 debug!("disr expr, checking %s",
                        pprust::expr_to_str(e, ccx.tcx.sess.intr()));
index 9cfa0187ab658b1790234d882b6161099bc39bf4..e865fe4c2e3958e2525ac94ecfe896fb915ca124 100644 (file)
@@ -28,6 +28,7 @@
 */
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use middle::freevars::get_freevars;
 use middle::ty::{re_scope};
@@ -268,7 +269,7 @@ fn visit_expr(expr: @ast::expr, rcx: @mut Rcx, v: rvt) {
         ast::expr_match(_, ref arms) => {
             tcx.region_maps.record_cleanup_scope(expr.id);
             for arms.each |arm| {
-                for arm.guard.each |guard| {
+                for arm.guard.iter().advance |guard| {
                     tcx.region_maps.record_cleanup_scope(guard.id);
                 }
             }
@@ -281,26 +282,29 @@ fn visit_expr(expr: @ast::expr, rcx: @mut Rcx, v: rvt) {
     }
 
     // Check any autoderefs or autorefs that appear.
-    for rcx.fcx.inh.adjustments.find(&expr.id).each |&adjustment| {
-        debug!("adjustment=%?", adjustment);
-        match *adjustment {
-            @ty::AutoDerefRef(
-                ty::AutoDerefRef {autoderefs: autoderefs, autoref: opt_autoref}) =>
-            {
-                let expr_ty = rcx.resolve_node_type(expr.id);
-                constrain_derefs(rcx, expr, autoderefs, expr_ty);
-                for opt_autoref.each |autoref| {
-                    guarantor::for_autoref(rcx, expr, autoderefs, autoref);
-
-                    // Require that the resulting region encompasses
-                    // the current node.
-                    //
-                    // FIXME(#6268) remove to support nested method calls
-                    constrain_regions_in_type_of_node(
-                        rcx, expr.id, ty::re_scope(expr.id), expr.span);
+    {
+        let r = rcx.fcx.inh.adjustments.find(&expr.id);
+        for r.iter().advance |&adjustment| {
+            debug!("adjustment=%?", adjustment);
+            match *adjustment {
+                @ty::AutoDerefRef(
+                    ty::AutoDerefRef {autoderefs: autoderefs, autoref: opt_autoref}) =>
+                {
+                    let expr_ty = rcx.resolve_node_type(expr.id);
+                    constrain_derefs(rcx, expr, autoderefs, expr_ty);
+                    for opt_autoref.iter().advance |autoref| {
+                        guarantor::for_autoref(rcx, expr, autoderefs, autoref);
+
+                        // Require that the resulting region encompasses
+                        // the current node.
+                        //
+                        // FIXME(#6268) remove to support nested method calls
+                        constrain_regions_in_type_of_node(
+                            rcx, expr.id, ty::re_scope(expr.id), expr.span);
+                    }
                 }
+                _ => {}
             }
-            _ => {}
         }
     }
 
@@ -489,7 +493,7 @@ fn constrain_call(rcx: @mut Rcx,
     }
 
     // as loop above, but for receiver
-    for receiver.each |&r| {
+    for receiver.iter().advance |&r| {
         constrain_regions_in_type_of_node(
             rcx, r.id, callee_region, r.span);
         if implicitly_ref_args {
@@ -871,9 +875,8 @@ fn maybe_make_subregion(
             rcx: @mut Rcx,
             expr: @ast::expr,
             sub_region: ty::Region,
-            sup_region: Option<ty::Region>)
-        {
-            for sup_region.each |r| {
+            sup_region: Option<ty::Region>) {
+            for sup_region.iter().advance |r| {
                 infallibly_mk_subr(rcx, true, expr.span, sub_region, *r);
             }
         }
@@ -895,7 +898,7 @@ pub fn for_by_ref(rcx: @mut Rcx,
         debug!("guarantor::for_by_ref(expr=%?, callee_scope=%?) category=%?",
                expr.id, callee_scope, expr_cat);
         let minimum_lifetime = ty::re_scope(callee_scope);
-        for expr_cat.guarantor.each |guarantor| {
+        for expr_cat.guarantor.iter().advance |guarantor| {
             mk_subregion_due_to_derefence(rcx, expr.span,
                                           minimum_lifetime, *guarantor);
         }
@@ -1201,12 +1204,12 @@ fn link_ref_bindings_in_pat(
             ast::pat_ident(ast::bind_by_ref(_), _, opt_p) => {
                 link(rcx, pat.span, pat.id, guarantor);
 
-                for opt_p.each |p| {
+                for opt_p.iter().advance |p| {
                     link_ref_bindings_in_pat(rcx, *p, guarantor);
                 }
             }
             ast::pat_ident(_, _, opt_p) => {
-                for opt_p.each |p| {
+                for opt_p.iter().advance |p| {
                     link_ref_bindings_in_pat(rcx, *p, guarantor);
                 }
             }
@@ -1245,7 +1248,7 @@ fn link_ref_bindings_in_pat(
                 };
 
                 link_ref_bindings_in_pats(rcx, before, guarantor1);
-                for slice.each |&p| {
+                for slice.iter().advance |&p| {
                     link_ref_bindings_in_pat(rcx, p, guarantor);
                 }
                 link_ref_bindings_in_pats(rcx, after, guarantor1);
index c1b33d317f1e3e6ed714afd4ade46710583a6a00..a5cfa629cf09925fba7644cee626db7ac5a5b476 100644 (file)
@@ -33,11 +33,11 @@ pub fn replace_bound_regions_in_fn_sig(
 {
     let mut all_tys = ty::tys_in_fn_sig(fn_sig);
 
-    for opt_self_ty.each |&self_ty| {
+    for opt_self_ty.iter().advance |&self_ty| {
         all_tys.push(self_ty);
     }
 
-    for opt_self_ty.each |&t| { all_tys.push(t) }
+    for opt_self_ty.iter().advance |&t| { all_tys.push(t) }
 
     debug!("replace_bound_regions_in_fn_sig(self_ty=%?, fn_sig=%s, \
             all_tys=%?)",
@@ -200,7 +200,7 @@ pub fn relate_nested_regions(
      */
 
     let mut the_stack = ~[];
-    for opt_region.each |&r| { the_stack.push(r); }
+    for opt_region.iter().advance |&r| { the_stack.push(r); }
     walk_ty(tcx, &mut the_stack, ty, relate_op);
 
     fn walk_ty(tcx: ty::ctxt,
@@ -262,7 +262,7 @@ pub fn relate_free_regions(
     for fn_sig.inputs.each |arg| {
         all_tys.push(*arg);
     }
-    for self_ty.each |&t| {
+    for self_ty.iter().advance |&t| {
         all_tys.push(t);
     }
 
index 4bf40d1c18eecbad9fc81b6f646c46238b569c6c..737abc2f6b540e0ae683406f15672917db729bb7 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use middle::resolve::Impl;
 use middle::ty::param_ty;
@@ -273,8 +274,8 @@ fn lookup_vtable(vcx: &VtableContext,
                         // same trait as trait_ref, we need to
                         // unify it with trait_ref in order to get all
                         // the ty vars sorted out.
-                        for ty::impl_trait_ref(tcx, im.did).each |&of_trait_ref|
-                        {
+                        let r = ty::impl_trait_ref(tcx, im.did);
+                        for r.iter().advance |&of_trait_ref| {
                             if of_trait_ref.def_id != trait_ref.def_id { loop; }
 
                             // At this point, we know that of_trait_ref is
index 68f9a43d6e67b6c763cb358106b6dc95cfec0384..d9ebaa2cb4a9c5b2cefd94bc5135ec60f0df2704 100644 (file)
@@ -13,6 +13,7 @@
 // substitutions.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use middle::pat_util;
 use middle::ty;
@@ -64,13 +65,16 @@ fn resolve_method_map_entry(fcx: @mut FnCtxt, sp: span, id: ast::node_id) {
     match fcx.inh.method_map.find(&id) {
         None => {}
         Some(mme) => {
-            for resolve_type_vars_in_type(fcx, sp, mme.self_ty).each |t| {
-                let method_map = fcx.ccx.method_map;
-                let new_entry = method_map_entry { self_ty: *t, ..*mme };
-                debug!("writeback::resolve_method_map_entry(id=%?, \
-                        new_entry=%?)",
-                       id, new_entry);
-                method_map.insert(id, new_entry);
+            {
+                let r = resolve_type_vars_in_type(fcx, sp, mme.self_ty);
+                for r.iter().advance |t| {
+                    let method_map = fcx.ccx.method_map;
+                    let new_entry = method_map_entry { self_ty: *t, ..*mme };
+                    debug!("writeback::resolve_method_map_entry(id=%?, \
+                            new_entry=%?)",
+                           id, new_entry);
+                    method_map.insert(id, new_entry);
+                }
             }
         }
     }
@@ -220,13 +224,19 @@ fn visit_expr(e: @ast::expr, wbcx: @mut WbCtxt, v: wb_vt) {
     resolve_type_vars_for_node(wbcx, e.span, e.id);
 
     resolve_method_map_entry(wbcx.fcx, e.span, e.id);
-    for e.get_callee_id().each |callee_id| {
-        resolve_method_map_entry(wbcx.fcx, e.span, *callee_id);
+    {
+        let r = e.get_callee_id();
+        for r.iter().advance |callee_id| {
+            resolve_method_map_entry(wbcx.fcx, e.span, *callee_id);
+        }
     }
 
     resolve_vtable_map_entry(wbcx.fcx, e.span, e.id);
-    for e.get_callee_id().each |callee_id| {
-        resolve_vtable_map_entry(wbcx.fcx, e.span, *callee_id);
+    {
+        let r = e.get_callee_id();
+        for r.iter().advance |callee_id| {
+            resolve_vtable_map_entry(wbcx.fcx, e.span, *callee_id);
+        }
     }
 
     match e.node {
@@ -327,7 +337,7 @@ pub fn resolve_type_vars_in_fn(fcx: @mut FnCtxt,
     let wbcx = @mut WbCtxt { fcx: fcx, success: true };
     let visit = mk_visitor();
     (visit.visit_block)(blk, wbcx, visit);
-    for self_info.each |self_info| {
+    for self_info.iter().advance |self_info| {
         resolve_type_vars_for_node(wbcx,
                                    self_info.span,
                                    self_info.self_id);
index dcf165b0496cfdb24cde67f28c35d5102c5ce789..450fe96ec9a96c8a58d2d563391797c91f55469f 100644 (file)
@@ -56,7 +56,6 @@
 
 use core::iterator::IteratorUtil;
 use core::hashmap::{HashMap, HashSet};
-use core::old_iter;
 use core::result::Ok;
 use core::uint;
 use core::vec;
@@ -213,7 +212,7 @@ pub fn check_coherence(self, crate: @crate) {
                 match item.node {
                     item_impl(_, opt_trait, _, _) => {
                         self.check_implementation(item,
-                                                  old_iter::to_vec(&opt_trait));
+                                                  opt_trait.iter().transform(|&x| x).collect());
                     }
                     _ => {
                         // Nothing to do.
@@ -808,7 +807,7 @@ fn add_provided_methods(all_methods: &mut ~[@MethodInfo],
                 }
 
                 // Check that we have implementations of every trait method
-                for trait_refs.each |trait_ref| {
+                for trait_refs.iter().advance |trait_ref| {
                     let trait_did =
                         self.trait_ref_to_trait_def_id(*trait_ref);
                     self.please_check_that_trait_methods_are_implemented(
@@ -821,7 +820,7 @@ fn add_provided_methods(all_methods: &mut ~[@MethodInfo],
                 // methods are provided.  For each of those methods,
                 // if a method of that name is not inherent to the
                 // impl, use the provided definition in the trait.
-                for trait_refs.each |trait_ref| {
+                for trait_refs.iter().advance |trait_ref| {
                     let trait_did =
                         self.trait_ref_to_trait_def_id(*trait_ref);
 
@@ -920,7 +919,7 @@ pub fn add_impls_for_module(&self,
             }
 
             // Record all the trait methods.
-            for associated_traits.each |trait_ref| {
+            for associated_traits.iter().advance |trait_ref| {
                 self.add_trait_method(trait_ref.def_id, *implementation);
             }
 
index a2c1211c5c46ecdf988472c2a0ef042ac9d8a07e..7cb342b78f7fcd31e82b00db56f34d05693d42d6 100644 (file)
@@ -31,6 +31,7 @@
 */
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use metadata::csearch;
 use middle::ty::{substs, ty_param_bounds_and_ty};
@@ -579,10 +580,10 @@ pub fn compare_impl_method(tcx: ty::ctxt,
     // For both the trait and the impl, create an argument to
     // represent the self argument (unless this is a static method).
     // This argument will have the *transformed* self type.
-    for trait_m.transformed_self_ty.each |&t| {
+    for trait_m.transformed_self_ty.iter().advance |&t| {
         trait_fn_args.push(t);
     }
-    for impl_m.transformed_self_ty.each |&t| {
+    for impl_m.transformed_self_ty.iter().advance |&t| {
         impl_fn_args.push(t);
     }
 
@@ -867,7 +868,7 @@ pub fn convert(ccx: &CrateCtxt, it: @ast::item) {
         let cms = convert_methods(ccx, *ms, selfty,
                                   &i_ty_generics, generics,
                                   parent_visibility);
-        for opt_trait_ref.each |t| {
+        for opt_trait_ref.iter().advance |t| {
             check_methods_against_trait(ccx, generics, rp, selfty, *t, cms);
         }
       }
index b791abb0ed2b3f0ba949a7c59fcc784c30a14deb..7ab51c36cf858465402c744c91d62c4215d277be 100644 (file)
@@ -269,6 +269,7 @@ fn bar() {
 
 use core::result;
 use core::vec;
+use core::iterator::IteratorUtil;
 use extra::list::Nil;
 use extra::smallintmap::SmallIntMap;
 use syntax::ast::{m_imm, m_mutbl};
@@ -766,7 +767,7 @@ pub fn type_error_message_str_with_expected(@mut self,
                         fmt!("%s%s", mk_msg(Some(self.ty_to_str(e)), actual_ty), error_str));
                 }
             }
-            for err.each |err| {
+            for err.iter().advance |err| {
                 ty::note_and_explain_type_err(self.tcx, *err)
             }
         }
index b5e6e7e119488cb7222fe37df1d589d62b8cf4c7..59f44c3c1f9c796fdb6dc126580cabaf11645d54 100644 (file)
@@ -32,6 +32,7 @@
 use syntax::print::pprust;
 use syntax::{ast, ast_util};
 
+use core::iterator::IteratorUtil;
 use core::str;
 use core::vec;
 
@@ -798,7 +799,7 @@ fn user_string(&self, tcx: ctxt) -> ~str {
         let base = ast_map::path_to_str(path, tcx.sess.intr());
         if tcx.sess.verbose() && self.substs.self_ty.is_some() {
             let mut all_tps = copy self.substs.tps;
-            for self.substs.self_ty.each |&t| { all_tps.push(t); }
+            for self.substs.self_ty.iter().advance |&t| { all_tps.push(t); }
             parameterized(tcx, base, self.substs.self_r, all_tps)
         } else {
             parameterized(tcx, base, self.substs.self_r,
index 7c4c63781240bdbebabe9d8c6fc101c4a1e902e4..a4a392e4bbbe1d87cbf24a8c3a84ae1707dd47b5 100644 (file)
@@ -131,7 +131,7 @@ fn stem_matches(&self, p: &Path) -> bool {
             return true;
         }
         else {
-            for self_id.each |pth| {
+            for self_id.iter().advance |pth| {
                 if pth.starts_with("rust_") // because p is already normalized
                     && match p.filestem() {
                            Some(s) => str::eq_slice(s, pth.slice(5, pth.len())),
index 2db51fe969fc415d8061f96d803947d8053545f6..387fa0d51d7e755390d919dae79dd629fbbc5ddc 100644 (file)
@@ -346,14 +346,14 @@ impl Ctx {
                target_exec.to_str(), target_lib,
                maybe_executable, maybe_library);
 
-        for maybe_executable.each |exec| {
+        for maybe_executable.iter().advance |exec| {
             debug!("Copying: %s -> %s", exec.to_str(), target_exec.to_str());
             if !(os::mkdir_recursive(&target_exec.dir_path(), u_rwx) &&
                  os::copy_file(exec, &target_exec)) {
                 cond.raise((copy *exec, copy target_exec));
             }
         }
-        for maybe_library.each |lib| {
+        for maybe_library.iter().advance |lib| {
             let target_lib = (copy target_lib).expect(fmt!("I built %s but apparently \
                                                 didn't install it!", lib.to_str()));
             debug!("Copying: %s -> %s", lib.to_str(), target_lib.to_str());
index b1400d1bc76f4c2b5870effb2788ed049c2656b6..7a9435d2ecd0b969c9f809e893bfba7f3f406368 100644 (file)
@@ -20,6 +20,7 @@
 use hash::Hash;
 use old_iter::BaseIter;
 use old_iter;
+use iterator::{Iterator, IteratorUtil};
 use option::{None, Option, Some};
 use rand::RngUtil;
 use rand;
@@ -316,7 +317,7 @@ fn contains_key(&self, k: &K) -> bool {
     /// Visit all key-value pairs
     fn each<'a>(&'a self, blk: &fn(&K, &'a V) -> bool) -> bool {
         for self.buckets.each |bucket| {
-            for bucket.each |pair| {
+            for bucket.iter().advance |pair| {
                 if !blk(&pair.key, &pair.value) {
                     return false;
                 }
index 8803844fdd01107ae92e104f8ce3fb7c2cabad32..bed74eba604ca9513b22a620980293c2b083fe0e 100644 (file)
@@ -49,12 +49,12 @@ pub trait IteratorUtil<A> {
     ///
     /// let a = [0];
     /// let b = [1];
-    /// let mut it = a.iter().chain(b.iter());
+    /// let mut it = a.iter().chain_(b.iter());
     /// assert_eq!(it.next().get(), &0);
     /// assert_eq!(it.next().get(), &1);
     /// assert!(it.next().is_none());
     /// ~~~
-    fn chain<U: Iterator<A>>(self, other: U) -> ChainIterator<A, Self, U>;
+    fn chain_<U: Iterator<A>>(self, other: U) -> ChainIterator<A, Self, U>;
 
     /// Creates an iterator which iterates over both this and the specified
     /// iterators simultaneously, yielding the two elements as pairs. When
@@ -191,6 +191,7 @@ pub trait IteratorUtil<A> {
     /// ~~~
     fn skip(self, n: uint) -> SkipIterator<A, Self>;
 
+    // FIXME: #5898: should be called take
     /// Creates an iterator which yields the first `n` elements of this
     /// iterator, and then it will always return None.
     ///
@@ -200,13 +201,13 @@ pub trait IteratorUtil<A> {
     /// use std::iterator::*;
     ///
     /// let a = [1, 2, 3, 4, 5];
-    /// let mut it = a.iter().take(3);
+    /// let mut it = a.iter().take_(3);
     /// assert_eq!(it.next().get(), &1);
     /// assert_eq!(it.next().get(), &2);
     /// assert_eq!(it.next().get(), &3);
     /// assert!(it.next().is_none());
     /// ~~~
-    fn take(self, n: uint) -> TakeIterator<A, Self>;
+    fn take_(self, n: uint) -> TakeIterator<A, Self>;
 
     /// Creates a new iterator which behaves in a similar fashion to foldl.
     /// There is a state which is passed between each iteration and can be
@@ -337,10 +338,10 @@ fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
     ///
     /// let a = [1, 2, 3, 4, 5];
     /// let mut it = a.iter();
-    /// assert!(it.any(|&x| *x == 3));
-    /// assert!(!it.any(|&x| *x == 3));
+    /// assert!(it.any_(|&x| *x == 3));
+    /// assert!(!it.any_(|&x| *x == 3));
     /// ~~~
-    fn any(&mut self, f: &fn(A) -> bool) -> bool;
+    fn any_(&mut self, f: &fn(A) -> bool) -> bool;
 }
 
 /// Iterator adaptors provided for every `Iterator` implementation. The adaptor objects are also
@@ -349,7 +350,7 @@ fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
 /// In the future these will be default methods instead of a utility trait.
 impl<A, T: Iterator<A>> IteratorUtil<A> for T {
     #[inline(always)]
-    fn chain<U: Iterator<A>>(self, other: U) -> ChainIterator<A, T, U> {
+    fn chain_<U: Iterator<A>>(self, other: U) -> ChainIterator<A, T, U> {
         ChainIterator{a: self, b: other, flag: false}
     }
 
@@ -394,8 +395,9 @@ fn skip(self, n: uint) -> SkipIterator<A, T> {
         SkipIterator{iter: self, n: n}
     }
 
+    // FIXME: #5898: should be called take
     #[inline(always)]
-    fn take(self, n: uint) -> TakeIterator<A, T> {
+    fn take_(self, n: uint) -> TakeIterator<A, T> {
         TakeIterator{iter: self, n: n}
     }
 
@@ -467,7 +469,7 @@ fn all(&mut self, f: &fn(A) -> bool) -> bool {
     }
 
     #[inline(always)]
-    fn any(&mut self, f: &fn(A) -> bool) -> bool {
+    fn any_(&mut self, f: &fn(A) -> bool) -> bool {
         for self.advance |x| { if f(x) { return true; } }
         return false;
     }
@@ -878,7 +880,7 @@ mod tests {
 
     #[test]
     fn test_counter_from_iter() {
-        let mut it = Counter::new(0, 5).take(10);
+        let mut it = Counter::new(0, 5).take_(10);
         let xs: ~[int] = iter::FromIter::from_iter::<int, ~[int]>(|f| it.advance(f));
         assert_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
     }
@@ -888,7 +890,7 @@ fn test_iterator_chain() {
         let xs = [0u, 1, 2, 3, 4, 5];
         let ys = [30u, 40, 50, 60];
         let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60];
-        let mut it = xs.iter().chain(ys.iter());
+        let mut it = xs.iter().chain_(ys.iter());
         let mut i = 0;
         for it.advance |&x| {
             assert_eq!(x, expected[i]);
@@ -896,8 +898,8 @@ fn test_iterator_chain() {
         }
         assert_eq!(i, expected.len());
 
-        let ys = Counter::new(30u, 10).take(4);
-        let mut it = xs.iter().transform(|&x| x).chain(ys);
+        let ys = Counter::new(30u, 10).take_(4);
+        let mut it = xs.iter().transform(|&x| x).chain_(ys);
         let mut i = 0;
         for it.advance |x| {
             assert_eq!(x, expected[i]);
@@ -908,7 +910,7 @@ fn test_iterator_chain() {
 
     #[test]
     fn test_filter_map() {
-        let mut it = Counter::new(0u, 1u).take(10)
+        let mut it = Counter::new(0u, 1u).take_(10)
             .filter_map(|x| if x.is_even() { Some(x*x) } else { None });
         assert_eq!(it.collect::<~[uint]>(), ~[0*0, 2*2, 4*4, 6*6, 8*8]);
     }
@@ -965,7 +967,7 @@ fn test_iterator_skip() {
     fn test_iterator_take() {
         let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
         let ys = [0u, 1, 2, 3, 5];
-        let mut it = xs.iter().take(5);
+        let mut it = xs.iter().take_(5);
         let mut i = 0;
         for it.advance |&x| {
             assert_eq!(x, ys[i]);
@@ -1088,9 +1090,9 @@ fn test_all() {
     #[test]
     fn test_any() {
         let v = ~&[1, 2, 3, 4, 5];
-        assert!(v.iter().any(|&x| x < 10));
-        assert!(v.iter().any(|&x| x.is_even()));
-        assert!(!v.iter().any(|&x| x > 100));
-        assert!(!v.slice(0, 0).iter().any(|_| fail!()));
+        assert!(v.iter().any_(|&x| x < 10));
+        assert!(v.iter().any_(|&x| x.is_even()));
+        assert!(!v.iter().any_(|&x| x > 100));
+        assert!(!v.slice(0, 0).iter().any_(|_| fail!()));
     }
 }
index 8855ad0e30f5093b32930a7b3871ca5b4d7be3f1..80f4fb7643c8081b908f3fe4a13a7811affa3d72 100644 (file)
 use kinds::Copy;
 use util;
 use num::Zero;
-use old_iter::{BaseIter, MutableIter, ExtendedIter};
-use old_iter;
 use iterator::Iterator;
 use str::StrSlice;
 use clone::DeepClone;
 
 #[cfg(test)] use str;
+#[cfg(test)] use iterator::IteratorUtil;
 
 /// The option type
 #[deriving(Clone, DeepClone, Eq)]
@@ -101,52 +100,8 @@ fn add(&self, other: &Option<T>) -> Option<T> {
     }
 }
 
-impl<T> BaseIter<T> for Option<T> {
-    /// Performs an operation on the contained value by reference
-    #[inline(always)]
-    fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) -> bool {
-        match *self { None => true, Some(ref t) => { f(t) } }
-    }
-
-    #[inline(always)]
-    fn size_hint(&self) -> Option<uint> {
-        if self.is_some() { Some(1) } else { Some(0) }
-    }
-}
-
-impl<T> MutableIter<T> for Option<T> {
-    #[inline(always)]
-    fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) -> bool {
-        match *self { None => true, Some(ref mut t) => { f(t) } }
-    }
-}
-
-impl<A> ExtendedIter<A> for Option<A> {
-    pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool {
-        old_iter::eachi(self, blk)
-    }
-    pub fn all(&self, blk: &fn(&A) -> bool) -> bool {
-        old_iter::all(self, blk)
-    }
-    pub fn any(&self, blk: &fn(&A) -> bool) -> bool {
-        old_iter::any(self, blk)
-    }
-    pub fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B {
-        old_iter::foldl(self, b0, blk)
-    }
-    pub fn position(&self, f: &fn(&A) -> bool) -> Option<uint> {
-        old_iter::position(self, f)
-    }
-    fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
-        old_iter::map_to_vec(self, op)
-    }
-    fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB)
-        -> ~[B] {
-        old_iter::flat_map_to_vec(self, op)
-    }
-}
-
 impl<T> Option<T> {
+    /// Return an iterator over the possibly contained value
     #[inline]
     pub fn iter<'r>(&'r self) -> OptionIterator<'r, T> {
         match *self {
@@ -155,6 +110,7 @@ pub fn iter<'r>(&'r self) -> OptionIterator<'r, T> {
         }
     }
 
+    /// Return a mutable iterator over the possibly contained value
     #[inline]
     pub fn mut_iter<'r>(&'r mut self) -> OptionMutIterator<'r, T> {
         match *self {
@@ -394,6 +350,7 @@ pub fn get_or_zero(self) -> T {
     }
 }
 
+/// Immutable iterator over an `Option<A>`
 pub struct OptionIterator<'self, A> {
     priv opt: Option<&'self A>
 }
@@ -404,6 +361,7 @@ fn next(&mut self) -> Option<&'self A> {
     }
 }
 
+/// Mutable iterator over an `Option<A>`
 pub struct OptionMutIterator<'self, A> {
     priv opt: Option<&'self mut A>
 }
@@ -467,7 +425,7 @@ fn test_option_dance() {
     let x = Some(());
     let mut y = Some(5);
     let mut y2 = 0;
-    for x.each |_x| {
+    for x.iter().advance |_x| {
         y2 = y.swap_unwrap();
     }
     assert_eq!(y2, 5);
index ab8965a679691ba01e1945db6f197f33bfa46397..66993fb90996319cf4219f863a26b2430b8b5df3 100644 (file)
@@ -1574,7 +1574,7 @@ fn homedir() {
         setenv("HOME", "");
         assert!(os::homedir().is_none());
 
-        for oldhome.each |s| { setenv("HOME", *s) }
+        for oldhome.iter().advance |s| { setenv("HOME", *s) }
     }
 
     #[test]
index 85015c9bc5e41f511f8859c7469cdf30a0aec35d..1492e44f047a584b80cea079b73c1e303b214410 100644 (file)
@@ -176,9 +176,9 @@ pub fn new(prog: &str, args: &[~str], options: ProcessOptions)
                                    in_fd, out_fd, err_fd);
 
         unsafe {
-            for in_pipe.each  |pipe| { libc::close(pipe.in); }
-            for out_pipe.each |pipe| { libc::close(pipe.out); }
-            for err_pipe.each |pipe| { libc::close(pipe.out); }
+            for in_pipe.iter().advance  |pipe| { libc::close(pipe.in); }
+            for out_pipe.iter().advance |pipe| { libc::close(pipe.out); }
+            for err_pipe.iter().advance |pipe| { libc::close(pipe.out); }
         }
 
         Process {
@@ -323,7 +323,7 @@ fn fclose_and_null(f_opt: &mut Option<*libc::FILE>) {
      * If the child has already been finished then the exit code is returned.
      */
     pub fn finish(&mut self) -> int {
-        for self.exit_code.each |&code| {
+        for self.exit_code.iter().advance |&code| {
             return code;
         }
         self.close_input();
index bc409e066330b69a5bfc0177232887f4f3cdacb7..780e9d6d923ed22a8f662832d24fccf02a474eba 100644 (file)
@@ -92,6 +92,7 @@
 use util;
 use unstable::sync::{Exclusive, exclusive};
 use rt::local::Local;
+use iterator::{Iterator, IteratorUtil};
 
 #[cfg(test)] use task::default_task_opts;
 #[cfg(test)] use comm;
@@ -276,7 +277,7 @@ fn iterate(ancestors:       &AncestorList,
                  * Step 3: Maybe unwind; compute return info for our caller.
                  *##########################################################*/
                 if need_unwind && !nobe_is_dead {
-                    for bail_opt.each |bail_blk| {
+                    for bail_opt.iter().advance |bail_blk| {
                         do with_parent_tg(&mut nobe.parent_group) |tg_opt| {
                             (*bail_blk)(tg_opt)
                         }
@@ -328,7 +329,7 @@ fn finalize(&self) {
 
             // If we are failing, the whole taskgroup needs to die.
             if rt::rust_task_is_unwinding(self.me) {
-                for this.notifier.each_mut |x| {
+                for this.notifier.mut_iter().advance |x| {
                     x.failed = true;
                 }
                 // Take everybody down with us.
@@ -357,7 +358,7 @@ fn TCB(me: *rust_task,
        ancestors: AncestorList,
        is_main: bool,
        mut notifier: Option<AutoNotify>) -> TCB {
-    for notifier.each_mut |x| {
+    for notifier.mut_iter().advance |x| {
         x.failed = false;
     }
 
index 9b74119b08cb5a9a0ed9bf22c733ffa35ba53f3c..8a6f58d7992e968d2b6581699961d68c1639fd85 100644 (file)
@@ -76,8 +76,8 @@
 
 */
 
-use cmp::Eq;
 use prelude::*;
+use iterator::IteratorUtil;
 
 /*
  * We have a 'ct' (compile-time) module that parses format strings into a
@@ -607,7 +607,7 @@ pub fn pad(cv: Conv, s: &str, head: Option<char>, mode: PadMode,
         let headsize = match head { Some(_) => 1, _ => 0 };
         let uwidth : uint = match cv.width {
             CountImplied => {
-                for head.each |&c| {
+                for head.iter().advance |&c| {
                     buf.push_char(c);
                 }
                 return buf.push_str(s);
@@ -616,7 +616,7 @@ pub fn pad(cv: Conv, s: &str, head: Option<char>, mode: PadMode,
         };
         let strlen = str::char_len(s) + headsize;
         if uwidth <= strlen {
-            for head.each |&c| {
+            for head.iter().advance |&c| {
                 buf.push_char(c);
             }
             return buf.push_str(s);
@@ -624,7 +624,7 @@ pub fn pad(cv: Conv, s: &str, head: Option<char>, mode: PadMode,
         let mut padchar = ' ';
         let diff = uwidth - strlen;
         if have_flag(cv.flags, flag_left_justify) {
-            for head.each |&c| {
+            for head.iter().advance |&c| {
                 buf.push_char(c);
             }
             buf.push_str(s);
@@ -658,7 +658,7 @@ fn have_precision(cv: Conv) -> bool {
         // instead.
 
         if signed && zero_padding {
-            for head.each |&head| {
+            for head.iter().advance |&head| {
                 if head == '+' || head == '-' || head == ' ' {
                     buf.push_char(head);
                     buf.push_str(padstr);
@@ -668,7 +668,7 @@ fn have_precision(cv: Conv) -> bool {
             }
         }
         buf.push_str(padstr);
-        for head.each |&c| {
+        for head.iter().advance |&c| {
             buf.push_char(c);
         }
         buf.push_str(s);
index 2e60f7d02dfbc56ab2f86ac8aa94ad637e87255d..42bba6d6aea76875aae4eb254b8847670fb1f648 100644 (file)
@@ -22,6 +22,7 @@
 use visit;
 use syntax::parse::token::special_idents;
 
+use core::iterator::IteratorUtil;
 use core::cmp;
 use core::hashmap::HashMap;
 use core::vec;
@@ -317,8 +318,11 @@ pub fn map_struct_def(
 pub fn map_expr(ex: @expr, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
     cx.map.insert(ex.id, node_expr(ex));
     // Expressions which are or might be calls:
-    for ex.get_callee_id().each |callee_id| {
-        cx.map.insert(*callee_id, node_callee_scope(ex));
+    {
+        let r = ex.get_callee_id();
+        for r.iter().advance |callee_id| {
+            cx.map.insert(*callee_id, node_callee_scope(ex));
+        }
     }
     visit::visit_expr(ex, cx, v);
 }
index 3d6269942fd5b4b2f837c40d24201ff0f8600333..c531f2ca5503fa4db5e692c8fa7245c8f1f080a2 100644 (file)
@@ -24,6 +24,7 @@
 use core::int;
 use core::option;
 use core::to_bytes;
+use core::iterator::IteratorUtil;
 
 pub fn path_name_i(idents: &[ident]) -> ~str {
     // FIXME: Bad copies (#2543 -- same for everything else that says "bad")
@@ -461,8 +462,11 @@ pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> {
         },
 
         visit_expr: |e, t, vt| {
-            for e.get_callee_id().each |callee_id| {
-                vfn(*callee_id, t);
+            {
+                let r = e.get_callee_id();
+                for r.iter().advance |callee_id| {
+                    vfn(*callee_id, t);
+                }
             }
             vfn(e.id, t);
             visit::visit_expr(e, t, vt);
@@ -553,8 +557,8 @@ pub fn walk_pat(pat: @pat, it: &fn(@pat) -> bool) -> bool {
         }
         pat_vec(ref before, ref slice, ref after) => {
             before.each(|&p| walk_pat(p, it)) &&
-                slice.each(|&p| walk_pat(p, it)) &&
-                after.each(|&p| walk_pat(p, it))
+                slice.iter().advance(|&p| walk_pat(p, it)) &&
+                after.iter().advance(|&p| walk_pat(p, it))
         }
         pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _, _) |
         pat_enum(_, _) => {
index 58b01fe78e7b8dcc020cb5df633e89ca9aace28c..1a2569ef78792e030ab25d46c1f753fe52fb407e 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use codemap::{Pos, span};
 use codemap;
@@ -304,7 +305,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
 }
 
 fn print_macro_backtrace(cm: @codemap::CodeMap, sp: span) {
-    for sp.expn_info.each |ei| {
+    for sp.expn_info.iter().advance |ei| {
         let ss = ei.callee.span.map_default(@~"", |span| @cm.span_to_str(*span));
         print_diagnostic(*ss, note,
                          fmt!("in expansion of %s!", ei.callee.name));
index 1e1f411c050ee886d2784eb8dfc342e09d4bb8a2..96ea5ecf92cae0842aaa0d21467c4c9c50b3df4a 100644 (file)
@@ -384,7 +384,9 @@ pub fn new_name_finder() -> @Visitor<@mut ~[ast::ident]> {
                         _ => ()
                     }
                     // visit optional subpattern of pat_ident:
-                    for inner.each |subpat: &@ast::pat| { (v.visit_pat)(*subpat, ident_accum, v) }
+                    for inner.iter().advance |subpat: &@ast::pat| {
+                        (v.visit_pat)(*subpat, ident_accum, v)
+                    }
                 }
                 // use the default traversal for non-pat_idents
                 _ => visit::visit_pat(p,ident_accum,v)
index 2157fec835eaf2ab1c917a376efaffd8a51da9ce..b6459fe30a355b44048290d31e90300b9738265a 100644 (file)
@@ -34,6 +34,7 @@
 use core::str;
 use core::u64;
 use core::uint;
+use core::iterator::IteratorUtil;
 
 // The @ps is stored here to prevent recursive type.
 pub enum ann_node<'self> {
@@ -371,7 +372,7 @@ pub fn print_foreign_mod(s: @ps, nmod: &ast::foreign_mod,
 }
 
 pub fn print_opt_lifetime(s: @ps, lifetime: Option<@ast::Lifetime>) {
-    for lifetime.each |l| {
+    for lifetime.iter().advance |l| {
         print_lifetime(s, *l);
         nbsp(s);
     }
@@ -1213,7 +1214,7 @@ fn print_field(s: @ps, field: ast::field) {
         print_block(s, blk);
       }
       ast::expr_loop(ref blk, opt_ident) => {
-        for opt_ident.each |ident| {
+        for opt_ident.iter().advance |ident| {
             word(s.s, "'");
             print_ident(s, *ident);
             word_space(s, ":");
@@ -1362,7 +1363,7 @@ fn print_field(s: @ps, field: ast::field) {
       ast::expr_break(opt_ident) => {
         word(s.s, "break");
         space(s.s);
-        for opt_ident.each |ident| {
+        for opt_ident.iter().advance |ident| {
             word(s.s, "'");
             print_ident(s, *ident);
             space(s.s);
@@ -1371,7 +1372,7 @@ fn print_field(s: @ps, field: ast::field) {
       ast::expr_again(opt_ident) => {
         word(s.s, "loop");
         space(s.s);
-        for opt_ident.each |ident| {
+        for opt_ident.iter().advance |ident| {
             word(s.s, "'");
             print_ident(s, *ident);
             space(s.s)
@@ -1498,7 +1499,7 @@ pub fn print_path(s: @ps, path: @ast::Path, colons_before_params: bool) {
         if path.rp.is_some() || !path.types.is_empty() {
             word(s.s, "<");
 
-            for path.rp.each |r| {
+            for path.rp.iter().advance |r| {
                 print_lifetime(s, *r);
                 if !path.types.is_empty() {
                     word_space(s, ",");
@@ -1613,7 +1614,7 @@ fn print_field(s: @ps, f: ast::field_pat, refutable: bool) {
         do commasep(s, inconsistent, *before) |s, p| {
             print_pat(s, p, refutable);
         }
-        for slice.each |&p| {
+        for slice.iter().advance |&p| {
             if !before.is_empty() { word_space(s, ","); }
             word(s.s, "..");
             print_pat(s, p, refutable);
@@ -1675,7 +1676,7 @@ pub fn print_fn_args(s: @ps, decl: &ast::fn_decl,
     // self type and the args all in the same box.
     box(s, 0u, inconsistent);
     let mut first = true;
-    for opt_explicit_self.each |explicit_self| {
+    for opt_explicit_self.iter().advance |explicit_self| {
         first = !print_explicit_self(s, *explicit_self);
     }
 
@@ -1922,7 +1923,7 @@ pub fn print_ty_fn(s: @ps,
     // self type and the args all in the same box.
     box(s, 0u, inconsistent);
     let mut first = true;
-    for opt_explicit_self.each |explicit_self| {
+    for opt_explicit_self.iter().advance |explicit_self| {
         first = !print_explicit_self(s, *explicit_self);
     }
     for decl.inputs.each |arg| {
index bf75efb805f2492a5a2a12138a39e9650508372b..4e4330c3c1bc57eb4bbc87867c0e4ab742c85110 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use abi::AbiSet;
 use ast::*;
@@ -189,7 +190,7 @@ pub fn visit_item<E: Copy>(i: @item, e: E, v: vt<E>) {
         }
         item_impl(ref tps, ref traits, ty, ref methods) => {
             (v.visit_generics)(tps, e, v);
-            for traits.each |&p| {
+            for traits.iter().advance |&p| {
                 visit_trait_ref(p, e, v);
             }
             (v.visit_ty)(ty, e, v);
@@ -227,7 +228,7 @@ pub fn visit_enum_def<E: Copy>(enum_definition: &ast::enum_def,
             }
         }
         // Visit the disr expr if it exists
-        for vr.node.disr_expr.each |ex| { (v.visit_expr)(*ex, e, v) }
+        for vr.node.disr_expr.iter().advance |ex| { (v.visit_expr)(*ex, e, v) }
     }
 }
 
@@ -269,8 +270,8 @@ pub fn visit_pat<E: Copy>(p: @pat, e: E, v: vt<E>) {
     match p.node {
         pat_enum(path, ref children) => {
             visit_path(path, e, v);
-            for children.each |children| {
-                for children.each |child| { (v.visit_pat)(*child, e, v); }
+            for children.iter().advance |children| {
+                for children.iter().advance |child| { (v.visit_pat)(*child, e, v); }
             }
         }
         pat_struct(path, ref fields, _) => {
@@ -289,7 +290,7 @@ pub fn visit_pat<E: Copy>(p: @pat, e: E, v: vt<E>) {
         },
         pat_ident(_, path, ref inner) => {
             visit_path(path, e, v);
-            for inner.each |subpat| { (v.visit_pat)(*subpat, e, v) }
+            for inner.iter().advance |subpat| { (v.visit_pat)(*subpat, e, v) }
         }
         pat_lit(ex) => (v.visit_expr)(ex, e, v),
         pat_range(e1, e2) => {
@@ -301,7 +302,7 @@ pub fn visit_pat<E: Copy>(p: @pat, e: E, v: vt<E>) {
             for before.each |elt| {
                 (v.visit_pat)(*elt, e, v);
             }
-            for slice.each |elt| {
+            for slice.iter().advance |elt| {
                 (v.visit_pat)(*elt, e, v);
             }
             for after.each |tail| {
@@ -550,7 +551,7 @@ pub fn visit_expr<E: Copy>(ex: @expr, e: E, v: vt<E>) {
 }
 
 pub fn visit_arm<E: Copy>(a: &arm, e: E, v: vt<E>) {
-    for a.pats.each |p| { (v.visit_pat)(*p, e, v); }
+    for a.pats.iter().advance |p| { (v.visit_pat)(*p, e, v); }
     visit_expr_opt(a.guard, e, v);
     (v.visit_block)(&a.body, e, v);
 }
index dee18c8a1b3ed9973c079c6c1559bdbd7c46ac22..bc3065fb2e6ba01c7e32de87067e5ec10aba421e 100644 (file)
@@ -112,7 +112,7 @@ fn gen_search_keys(graph: &[~[node_id]], n: uint) -> ~[node_id] {
     while keys.len() < n {
         let k = r.gen_uint_range(0u, graph.len());
 
-        if graph[k].len() > 0u && graph[k].iter().any(|i| {
+        if graph[k].len() > 0u && graph[k].iter().any_(|i| {
             *i != k as node_id
         }) {
             keys.insert(k as node_id);
@@ -188,7 +188,7 @@ fn is_gray(c: &color) -> bool {
     }
 
     let mut i = 0;
-    while colors.iter().any(is_gray) {
+    while colors.iter().any_(is_gray) {
         // Do the BFS.
         info!("PBFS iteration %?", i);
         i += 1;
index c34948a897937633b606eb25030d78c338d15d14..be575f64462bed3f67df3bc907a221a53ec3170d 100644 (file)
@@ -21,20 +21,20 @@ pub fn main() {
     }
 
     // Usable at all:
-    let mut any_negative = do v.iter().any |e| { e.is_negative() };
+    let mut any_negative = do v.iter().any_ |e| { e.is_negative() };
     assert!(any_negative);
 
     // Higher precedence than assignments:
-    any_negative = do v.iter().any |e| { e.is_negative() };
+    any_negative = do v.iter().any_ |e| { e.is_negative() };
     assert!(any_negative);
 
     // Higher precedence than unary operations:
     let abs_v = do vec::map(v) |e| { e.abs() };
     assert!(do abs_v.iter().all |e| { e.is_positive() });
-    assert!(!do abs_v.iter().any |e| { e.is_negative() });
+    assert!(!do abs_v.iter().any_ |e| { e.is_negative() });
 
     // Usable in funny statement-like forms:
-    if !do v.iter().any |e| { e.is_positive() } {
+    if !do v.iter().any_ |e| { e.is_positive() } {
         assert!(false);
     }
     match do v.iter().all |e| { e.is_negative() } {
@@ -42,7 +42,7 @@ pub fn main() {
         false => { }
     }
     match 3 {
-      _ if do v.iter().any |e| { e.is_negative() } => {
+      _ if do v.iter().any_ |e| { e.is_negative() } => {
       }
       _ => {
         fail!("wrong answer.");
@@ -59,7 +59,7 @@ pub fn main() {
 
     // In the tail of a block
     let w =
-        if true { do abs_v.iter().any |e| { e.is_positive() } }
+        if true { do abs_v.iter().any_ |e| { e.is_positive() } }
       else { false };
     assert!(w);
 }
index 57f4a41fee94b71ab4a83871bac4daa2bd33ffe0..2507c1d6def899cdaaed53edaa42827bf70de4ed 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::old_iter;
-
 trait thing<A> {
     fn foo(&self) -> Option<A>;
 }
@@ -21,10 +19,5 @@ fn foo_func<A, B: thing<A>>(x: B) -> Option<A> { x.foo() }
 struct A { a: int }
 
 pub fn main() {
-
-    for old_iter::eachi(&(Some(A {a: 0}))) |i, a| {
-        debug!("%u %d", i, a.a);
-    }
-
     let _x: Option<float> = foo_func(0);
 }
diff --git a/src/test/run-pass/iter-all.rs b/src/test/run-pass/iter-all.rs
deleted file mode 100644 (file)
index b3177d1..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-fn is_even(x: &uint) -> bool { (*x % 2) == 0 }
-
-pub fn main() {
-    assert!(![1u, 2u].all(is_even));
-    assert!([2u, 4u].all(is_even));
-    assert!([].all(is_even));
-
-    assert!(!old_iter::all(&Some(1u), is_even));
-    assert!(old_iter::all(&Some(2u), is_even));
-    assert!(old_iter::all(&None::<uint>, is_even));
-}
diff --git a/src/test/run-pass/iter-any.rs b/src/test/run-pass/iter-any.rs
deleted file mode 100644 (file)
index 08a89f8..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-fn is_even(x: &uint) -> bool { (*x % 2) == 0 }
-
-pub fn main() {
-    assert!(![1u, 3u].any(is_even));
-    assert!([1u, 2u].any(is_even));
-    assert!(![].any(is_even));
-
-    assert!(!old_iter::any(&Some(1u), is_even));
-    assert!(old_iter::any(&Some(2u), is_even));
-    assert!(!old_iter::any(&None::<uint>, is_even));
-}
diff --git a/src/test/run-pass/iter-contains.rs b/src/test/run-pass/iter-contains.rs
deleted file mode 100644 (file)
index 5034102..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-pub fn main() {
-    assert_eq!([].contains(&22u), false);
-    assert_eq!([1u, 3u].contains(&22u), false);
-    assert_eq!([22u, 1u, 3u].contains(&22u), true);
-    assert_eq!([1u, 22u, 3u].contains(&22u), true);
-    assert_eq!([1u, 3u, 22u].contains(&22u), true);
-    assert_eq!(old_iter::contains(&None::<uint>, &22u), false);
-    assert_eq!(old_iter::contains(&Some(1u), &22u), false);
-    assert_eq!(old_iter::contains(&Some(22u), &22u), true);
-}
diff --git a/src/test/run-pass/iter-count.rs b/src/test/run-pass/iter-count.rs
deleted file mode 100644 (file)
index 3f867e4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-pub fn main() {
-    assert_eq!([].count(&22u), 0u);
-    assert_eq!([1u, 3u].count(&22u), 0u);
-    assert_eq!([22u, 1u, 3u].count(&22u), 1u);
-    assert_eq!([22u, 1u, 22u].count(&22u), 2u);
-    assert_eq!(old_iter::count(&None::<uint>, &22u), 0u);
-    assert_eq!(old_iter::count(&Some(1u), &22u), 0u);
-    assert_eq!(old_iter::count(&Some(22u), &22u), 1u);
-}
diff --git a/src/test/run-pass/iter-eachi.rs b/src/test/run-pass/iter-eachi.rs
deleted file mode 100644 (file)
index 0740f2c..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-pub fn main() {
-    let mut c = 0u;
-    for [1u, 2u, 3u, 4u, 5u].eachi |i, v| {
-        assert_eq!((i + 1u), *v);
-        c += 1u;
-    }
-    assert_eq!(c, 5u);
-
-    for old_iter::eachi(&None::<uint>) |i, v| { fail!(); }
-
-    let mut c = 0u;
-    for old_iter::eachi(&Some(1u)) |i, v| {
-        assert_eq!((i + 1u), *v);
-        c += 1u;
-    }
-    assert_eq!(c, 1u);
-}
diff --git a/src/test/run-pass/iter-filter-to-vec.rs b/src/test/run-pass/iter-filter-to-vec.rs
deleted file mode 100644 (file)
index 2b25476..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-fn is_even(x: &uint) -> bool { (*x % 2) == 0 }
-
-pub fn main() {
-    assert_eq!([1, 3].filter_to_vec(is_even), ~[]);
-    assert_eq!([1, 2, 3].filter_to_vec(is_even), ~[2]);
-    assert_eq!(old_iter::filter_to_vec(&None::<uint>, is_even), ~[]);
-    assert_eq!(old_iter::filter_to_vec(&Some(1u), is_even), ~[]);
-    assert_eq!(old_iter::filter_to_vec(&Some(2u), is_even), ~[2]);
-}
diff --git a/src/test/run-pass/iter-flat-map-to-vec.rs b/src/test/run-pass/iter-flat-map-to-vec.rs
deleted file mode 100644 (file)
index b0b61aa..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-fn repeat(x: &uint) -> ~[uint] { ~[*x, *x] }
-
-fn incd_if_even(x: &uint) -> Option<uint> {
-    if (*x % 2u) == 0u {Some(*x + 1u)} else {None}
-}
-
-pub fn main() {
-    assert_eq!((~[1u, 3u]).flat_map_to_vec(repeat), ~[1u, 1u, 3u, 3u]);
-    assert_eq!((~[]).flat_map_to_vec(repeat), ~[]);
-    assert_eq!(old_iter::flat_map_to_vec(&None::<uint>, repeat), ~[]);
-    assert_eq!(old_iter::flat_map_to_vec(&Some(1u), repeat), ~[1u, 1u]);
-    assert_eq!(old_iter::flat_map_to_vec(&Some(2u), repeat), ~[2u, 2u]);
-
-    assert_eq!((~[1u, 2u, 5u]).flat_map_to_vec(incd_if_even), ~[3u]);
-    assert_eq!((~[]).flat_map_to_vec(incd_if_even), ~[]);
-    assert_eq!(old_iter::flat_map_to_vec(&None::<uint>, incd_if_even), ~[]);
-    assert_eq!(old_iter::flat_map_to_vec(&Some(1u), incd_if_even), ~[]);
-    assert_eq!(old_iter::flat_map_to_vec(&Some(2u), incd_if_even), ~[3u]);
-}
diff --git a/src/test/run-pass/iter-foldl.rs b/src/test/run-pass/iter-foldl.rs
deleted file mode 100644 (file)
index 7e5890b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-fn add(x: &float, y: &uint) -> float { *x + ((*y) as float) }
-
-pub fn main() {
-    assert_eq!([1u, 3u].foldl(20f, add), 24f);
-    assert_eq!([].foldl(20f, add), 20f);
-    assert_eq!(old_iter::foldl(&None::<uint>, 20f, add), 20f);
-    assert_eq!(old_iter::foldl(&Some(1u), 20f, add), 21f);
-    assert_eq!(old_iter::foldl(&Some(2u), 20f, add), 22f);
-}
diff --git a/src/test/run-pass/iter-map-to-vec.rs b/src/test/run-pass/iter-map-to-vec.rs
deleted file mode 100644 (file)
index 706f0c5..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-fn inc(x: &uint) -> uint { *x + 1 }
-
-pub fn main() {
-    assert_eq!([1, 3].map_to_vec(inc), ~[2, 4]);
-    assert_eq!([1, 2, 3].map_to_vec(inc), ~[2, 3, 4]);
-    assert_eq!(old_iter::map_to_vec(&None::<uint>, inc), ~[]);
-    assert_eq!(old_iter::map_to_vec(&Some(1u), inc), ~[2]);
-    assert_eq!(old_iter::map_to_vec(&Some(2u), inc), ~[3]);
-}
diff --git a/src/test/run-pass/iter-min-max.rs b/src/test/run-pass/iter-min-max.rs
deleted file mode 100644 (file)
index 9020976..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-fn is_even(x: uint) -> bool { (x % 2u) == 0u }
-
-pub fn main() {
-    assert_eq!([1u, 3u].min(), 1u);
-    assert_eq!([3u, 1u].min(), 1u);
-    assert_eq!(old_iter::min(&Some(1u)), 1u);
-
-    assert_eq!([1u, 3u].max(), 3u);
-    assert_eq!([3u, 1u].max(), 3u);
-    assert_eq!(old_iter::max(&Some(3u)), 3u);
-}
diff --git a/src/test/run-pass/iter-to-vec.rs b/src/test/run-pass/iter-to-vec.rs
deleted file mode 100644 (file)
index 317b608..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::old_iter;
-
-pub fn main() {
-    assert_eq!([1u, 3u].to_vec(), ~[1u, 3u]);
-    let e: ~[uint] = ~[];
-    assert_eq!(e.to_vec(), ~[]);
-    assert_eq!(old_iter::to_vec(&None::<uint>), ~[]);
-    assert_eq!(old_iter::to_vec(&Some(1u)), ~[1u]);
-    assert_eq!(old_iter::to_vec(&Some(2u)), ~[2u]);
-}
index cbfaa87b69952aa7731adc99cc1aaa78557376d0..ef1107803037fb200d3ccbd1b18b2f671c1826d5 100644 (file)
@@ -31,8 +31,8 @@ fn checktests() {
     let tests = __test::tests;
 
     assert!(
-        tests.iter().any(|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore));
+        tests.iter().any_(|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore));
 
     assert!(
-        tests.iter().any(|t| t.desc.name.to_str() == ~"shouldnotignore" && !t.desc.ignore));
+        tests.iter().any_(|t| t.desc.name.to_str() == ~"shouldnotignore" && !t.desc.ignore));
 }