diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-06-10 17:50:12 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-06-11 14:06:12 -0400 |
| commit | 004816f4c6fa3902c69667761f52afb04cb2d62f (patch) | |
| tree | 7f974cb9391f138d75d5cfd2dafc0d1b421fcb68 /src/libsyntax | |
| parent | 4f2f545ac2ce19034b138006e7ac76e502b3188b (diff) | |
| download | rust-004816f4c6fa3902c69667761f52afb04cb2d62f.tar.gz rust-004816f4c6fa3902c69667761f52afb04cb2d62f.zip | |
option: remove redundant old_iter impls
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 17 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 15 |
6 files changed, 36 insertions, 23 deletions
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 2e60f7d02df..42bba6d6aea 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -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,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); } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 3d6269942fd..c531f2ca550 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -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,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(_, _) => { diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 58b01fe78e7..1a2569ef787 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -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)); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 1e1f411c050..96ea5ecf92c 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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) diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 2157fec835e..b6459fe30a3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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| { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index bf75efb805f..4e4330c3c1b 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -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); } |
