option: remove redundant old_iter impls
This commit is contained in:
parent
4f2f545ac2
commit
004816f4c6
70 changed files with 446 additions and 636 deletions
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ impl<T: TotalOrd> Set<T> for 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 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
|
|||
a = x.next();
|
||||
}
|
||||
}
|
||||
return b.each(|&x| f(x)) && y.advance(f);
|
||||
b.iter().advance(|&x| f(x)) && y.advance(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,13 +527,13 @@ impl<K: TotalOrd, 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) &&
|
||||
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) &&
|
||||
node.iter().advance(|x| each_reverse(&x.right, f) && f(&x.key, &x.value) &&
|
||||
each_reverse(&x.left, f))
|
||||
}
|
||||
|
||||
|
@ -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 remove<K: TotalOrd, V>(node: &mut Option<~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 @@ mod test_set {
|
|||
|
||||
let mut n = 0;
|
||||
for m.each |x| {
|
||||
println(fmt!("%?", x));
|
||||
assert_eq!(*x, n);
|
||||
n += 1
|
||||
}
|
||||
|
|
|
@ -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()) },
|
||||
|
|
|
@ -22,6 +22,7 @@ use middle::ty;
|
|||
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 encode_info_for_item(ecx: @EncodeContext,
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ use middle::{ty, typeck, moves};
|
|||
use middle;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::iterator::IteratorUtil;
|
||||
use core::at_vec;
|
||||
use core::uint;
|
||||
use extra::ebml::reader;
|
||||
|
@ -826,7 +827,9 @@ 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| {
|
||||
{
|
||||
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| {
|
||||
|
@ -834,8 +837,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for tcx.node_types.find(&(id as uint)).each |&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| {
|
||||
|
@ -843,8 +849,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for tcx.node_type_substs.find(&id).each |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| {
|
||||
|
@ -852,8 +861,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for tcx.freevars.find(&id).each |&fv| {
|
||||
{
|
||||
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| {
|
||||
|
@ -863,9 +875,12 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let lid = ast::def_id { crate: ast::local_crate, node: id };
|
||||
for tcx.tcache.find(&lid).each |&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| {
|
||||
|
@ -873,8 +888,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for tcx.ty_param_defs.find(&id).each |&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| {
|
||||
|
@ -882,8 +900,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for maps.method_map.find(&id).each |&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| {
|
||||
|
@ -891,8 +912,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for maps.vtable_map.find(&id).each |&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| {
|
||||
|
@ -900,8 +924,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for tcx.adjustments.find(&id).each |adj| {
|
||||
{
|
||||
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| {
|
||||
|
@ -909,6 +936,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if maps.moves_map.contains(&id) {
|
||||
do ebml_w.tag(c::tag_table_moves_map) |ebml_w| {
|
||||
|
@ -916,7 +944,9 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
|
||||
for maps.capture_map.find(&id).each |&cap_vars| {
|
||||
{
|
||||
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| {
|
||||
|
@ -926,6 +956,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait doc_decoder_helpers {
|
||||
|
|
|
@ -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 @@ impl<'self> CheckLoanCtxt<'self> {
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,14 +177,20 @@ fn gather_loans_in_expr(ex: @ast::expr,
|
|||
|
||||
this.id_range.add(ex.id);
|
||||
|
||||
for ex.get_callee_id().each |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| {
|
||||
{
|
||||
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:
|
||||
if this.bccx.is_move(ex.id) {
|
||||
|
|
|
@ -16,6 +16,7 @@ comments in the section "Moves and initialization" and in `doc.rs`.
|
|||
*/
|
||||
|
||||
use core::prelude::*;
|
||||
use core::iterator::IteratorUtil;
|
||||
|
||||
use core::hashmap::{HashMap, HashSet};
|
||||
use core::uint;
|
||||
|
@ -516,7 +517,7 @@ impl FlowedMoveData {
|
|||
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`
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -794,7 +794,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,7 +245,9 @@ 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 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));
|
||||
|
@ -273,6 +275,7 @@ pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
|
|||
check_bounds(cx, type_parameter_id, e.span, ty, type_param_def)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match e.node {
|
||||
expr_cast(source, _) => {
|
||||
|
@ -306,7 +309,8 @@ 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 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;
|
||||
|
|
|
@ -15,6 +15,7 @@ use middle::ty;
|
|||
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 @@ impl Context {
|
|||
allow => fail!(),
|
||||
}
|
||||
|
||||
for note.each |&span| {
|
||||
for note.iter().advance |&span| {
|
||||
self.tcx.sess.span_note(span, "lint level defined here");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,6 @@ use core::iterator::IteratorUtil;
|
|||
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 @@ impl Liveness {
|
|||
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 @@ impl Liveness {
|
|||
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 @@ impl Liveness {
|
|||
fmt!("unused variable: `%s`", **name));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn warn_about_dead_assign(&self,
|
||||
|
@ -1655,7 +1656,8 @@ impl Liveness {
|
|||
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));
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
*/
|
||||
|
||||
use core::prelude::*;
|
||||
use core::iterator::IteratorUtil;
|
||||
|
||||
use middle::ty;
|
||||
use middle::typeck;
|
||||
|
@ -948,7 +949,7 @@ impl mem_categorization_ctxt {
|
|||
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);
|
||||
|
|
|
@ -127,6 +127,7 @@ and so on.
|
|||
*/
|
||||
|
||||
use core::prelude::*;
|
||||
use core::iterator::IteratorUtil;
|
||||
|
||||
use middle::pat_util::{pat_bindings};
|
||||
use middle::freevars;
|
||||
|
@ -267,7 +268,7 @@ impl 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 @@ impl VisitContext {
|
|||
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 @@ impl VisitContext {
|
|||
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 @@ impl VisitContext {
|
|||
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 @@ impl VisitContext {
|
|||
}
|
||||
|
||||
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 @@ impl VisitContext {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ use middle::ty::{region_variance, rv_covariant, rv_invariant};
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1036,13 +1036,16 @@ impl Resolver {
|
|||
fmt!("duplicate definition of %s `%s`",
|
||||
namespace_to_str(ns),
|
||||
*self.session.str_of(name)));
|
||||
for child.span_for_namespace(ns).each |sp| {
|
||||
{
|
||||
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 @@ impl Resolver {
|
|||
// 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,9 +3910,12 @@ impl Resolver {
|
|||
|
||||
// Record the current set of trait references.
|
||||
let mut new_trait_refs = ~[];
|
||||
for self.def_map.find(&trait_reference.ref_id).each |&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,
|
||||
Some(new_trait_refs)));
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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,11 +1313,13 @@ 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| {
|
||||
{
|
||||
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);
|
||||
inf.cleanup_paths.push(cleanup_path {
|
||||
|
@ -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)",
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
// closure.
|
||||
|
||||
use core::prelude::*;
|
||||
use core::iterator::IteratorUtil;
|
||||
|
||||
use back::abi;
|
||||
use driver::session;
|
||||
|
@ -582,10 +583,13 @@ 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, _)| {
|
||||
{
|
||||
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);
|
||||
bcx
|
||||
|
|
|
@ -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)};
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -152,6 +152,7 @@ use middle::ty;
|
|||
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)
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -242,7 +242,9 @@ 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| {
|
||||
{
|
||||
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);
|
||||
|
@ -257,19 +259,23 @@ pub fn mark_for_method_call(cx: Context, e_id: node_id, callee_id: node_id) {
|
|||
| typeck::method_super(*) => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Note: we do not execute this code from within the each() call
|
||||
// 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| {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mark_for_expr(cx: Context, e: @expr) {
|
||||
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1017,7 +1017,7 @@ fn mk_t(cx: ctxt, st: sty) -> t {
|
|||
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 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
|
|||
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 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
|
|||
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)
|
||||
}
|
||||
|
|
|
@ -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| {
|
||||
|
|
|
@ -332,14 +332,14 @@ impl<'self> LookupContext<'self> {
|
|||
// 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 @@ impl<'self> LookupContext<'self> {
|
|||
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);
|
||||
|
|
|
@ -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 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
|||
};
|
||||
|
||||
// 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 @@ pub fn check_enum_variants(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()));
|
||||
|
|
|
@ -28,6 +28,7 @@ this point a bit better.
|
|||
*/
|
||||
|
||||
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,7 +282,9 @@ 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| {
|
||||
{
|
||||
let r = rcx.fcx.inh.adjustments.find(&expr.id);
|
||||
for r.iter().advance |&adjustment| {
|
||||
debug!("adjustment=%?", adjustment);
|
||||
match *adjustment {
|
||||
@ty::AutoDerefRef(
|
||||
|
@ -289,7 +292,7 @@ fn visit_expr(expr: @ast::expr, rcx: @mut Rcx, v: rvt) {
|
|||
{
|
||||
let expr_ty = rcx.resolve_node_type(expr.id);
|
||||
constrain_derefs(rcx, expr, autoderefs, expr_ty);
|
||||
for opt_autoref.each |autoref| {
|
||||
for opt_autoref.iter().advance |autoref| {
|
||||
guarantor::for_autoref(rcx, expr, autoderefs, autoref);
|
||||
|
||||
// Require that the resulting region encompasses
|
||||
|
@ -303,6 +306,7 @@ fn visit_expr(expr: @ast::expr, rcx: @mut Rcx, v: rvt) {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match expr.node {
|
||||
ast::expr_call(callee, ref args, _) => {
|
||||
|
@ -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 @@ pub mod guarantor {
|
|||
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 mod guarantor {
|
|||
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 @@ pub mod guarantor {
|
|||
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 @@ pub mod guarantor {
|
|||
};
|
||||
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// substitutions.
|
||||
|
||||
use core::prelude::*;
|
||||
use core::iterator::IteratorUtil;
|
||||
|
||||
use middle::pat_util;
|
||||
use middle::ty;
|
||||
|
@ -64,7 +65,9 @@ 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 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=%?, \
|
||||
|
@ -74,6 +77,7 @@ fn resolve_method_map_entry(fcx: @mut FnCtxt, sp: span, id: ast::node_id) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_vtable_map_entry(fcx: @mut FnCtxt, sp: span, id: ast::node_id) {
|
||||
|
@ -220,14 +224,20 @@ 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| {
|
||||
{
|
||||
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| {
|
||||
{
|
||||
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 {
|
||||
ast::expr_fn_block(ref decl, _) => {
|
||||
|
@ -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);
|
||||
|
|
|
@ -56,7 +56,6 @@ use util::ppaux::ty_to_str;
|
|||
|
||||
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 @@ impl CoherenceChecker {
|
|||
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 @@ impl CoherenceChecker {
|
|||
}
|
||||
|
||||
// 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 @@ impl CoherenceChecker {
|
|||
// 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 @@ impl CoherenceChecker {
|
|||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ are represented as `ty_param()` instances.
|
|||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,6 +269,7 @@ use util::ppaux::{bound_region_to_str, ty_to_str, trait_ref_to_str};
|
|||
|
||||
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 @@ impl InferCtxt {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ use syntax::parse::token;
|
|||
use syntax::print::pprust;
|
||||
use syntax::{ast, ast_util};
|
||||
|
||||
use core::iterator::IteratorUtil;
|
||||
use core::str;
|
||||
use core::vec;
|
||||
|
||||
|
@ -798,7 +799,7 @@ impl UserString for ty::TraitRef {
|
|||
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,
|
||||
|
|
|
@ -131,7 +131,7 @@ impl PkgSrc {
|
|||
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())),
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -20,6 +20,7 @@ use cmp::{Eq, Equiv};
|
|||
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 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
|
|||
/// 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;
|
||||
}
|
||||
|
|
|
@ -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 @@ pub trait IteratorUtil<A> {
|
|||
///
|
||||
/// 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 @@ pub trait IteratorUtil<A> {
|
|||
/// 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 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for 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 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
|
|||
}
|
||||
|
||||
#[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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
}
|
||||
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 @@ mod tests {
|
|||
|
||||
#[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 @@ mod tests {
|
|||
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 @@ mod tests {
|
|||
#[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!()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,13 +46,12 @@ use ops::Add;
|
|||
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 @@ impl<T: Copy + Add<T,T>> Add<Option<T>, Option<T>> for 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 @@ impl<T> Option<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 @@ impl<T:Copy + Zero> Option<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Immutable iterator over an `Option<A>`
|
||||
pub struct OptionIterator<'self, A> {
|
||||
priv opt: Option<&'self A>
|
||||
}
|
||||
|
@ -404,6 +361,7 @@ impl<'self, A> Iterator<&'self A> for OptionIterator<'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);
|
||||
|
|
|
@ -1574,7 +1574,7 @@ mod tests {
|
|||
setenv("HOME", "");
|
||||
assert!(os::homedir().is_none());
|
||||
|
||||
for oldhome.each |s| { setenv("HOME", *s) }
|
||||
for oldhome.iter().advance |s| { setenv("HOME", *s) }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -176,9 +176,9 @@ impl Process {
|
|||
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 @@ impl Process {
|
|||
* 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();
|
||||
|
|
|
@ -92,6 +92,7 @@ use uint;
|
|||
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 each_ancestor(list: &mut 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 @@ impl Drop for TCB {
|
|||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@ debug!("hello, %s!", "world");
|
|||
|
||||
*/
|
||||
|
||||
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 mod rt {
|
|||
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 mod rt {
|
|||
};
|
||||
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 mod rt {
|
|||
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 @@ pub mod rt {
|
|||
// 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 @@ pub mod rt {
|
|||
}
|
||||
}
|
||||
buf.push_str(padstr);
|
||||
for head.each |&c| {
|
||||
for head.iter().advance |&c| {
|
||||
buf.push_char(c);
|
||||
}
|
||||
buf.push_str(s);
|
||||
|
|
|
@ -22,6 +22,7 @@ use print::pprust;
|
|||
use visit;
|
||||
use syntax::parse::token::special_idents;
|
||||
|
||||
use core::iterator::IteratorUtil;
|
||||
use core::cmp;
|
||||
use core::hashmap::HashMap;
|
||||
use core::vec;
|
||||
|
@ -317,9 +318,12 @@ 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| {
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ use core::hashmap::HashMap;
|
|||
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,9 +462,12 @@ 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| {
|
||||
{
|
||||
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(_, _) => {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -34,6 +34,7 @@ use core::io;
|
|||
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 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
|
|||
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 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
|
|||
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 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
|
|||
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 @@ pub fn print_pat(s: @ps, pat: @ast::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| {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 bfs2(graph: graph, key: node_id) -> bfs_result {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
|
@ -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));
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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]);
|
||||
}
|
|
@ -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]);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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]);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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]);
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue