about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-08 10:25:15 -0700
committerbors <bors@rust-lang.org>2013-06-08 10:25:15 -0700
commitb8fa9d3be10e952fbcaf14f3098aebf13dedd7ec (patch)
treef99d1c8374844ccf7a3368110d3e33c0e51f18bb /src/libsyntax/ext
parente2ec8e71cec0373616953f8188cf7c4953269af0 (diff)
parent98ba91f81bea38d8fc8bd5bc0cb44ac3e173a53c (diff)
downloadrust-b8fa9d3be10e952fbcaf14f3098aebf13dedd7ec.tar.gz
rust-b8fa9d3be10e952fbcaf14f3098aebf13dedd7ec.zip
auto merge of #7015 : huonw/rust/each-fn-kill, r=thestinger
Continuation of #6995/#6999.
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/bytes.rs3
-rw-r--r--src/libsyntax/ext/deriving/generic.rs8
-rw-r--r--src/libsyntax/ext/deriving/iter_bytes.rs4
-rw-r--r--src/libsyntax/ext/deriving/mod.rs3
-rw-r--r--src/libsyntax/ext/expand.rs21
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs4
-rw-r--r--src/libsyntax/ext/tt/transcribe.rs10
7 files changed, 26 insertions, 27 deletions
diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs
index a046395b6f5..51fbaee7a33 100644
--- a/src/libsyntax/ext/bytes.rs
+++ b/src/libsyntax/ext/bytes.rs
@@ -10,6 +10,7 @@
 
 /* The compiler code necessary to support the bytes! extension. */
 
+use core::iterator::IteratorUtil;
 use ast;
 use codemap::span;
 use ext::base::*;
@@ -27,7 +28,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> bas
             ast::expr_lit(lit) => match lit.node {
                 // string literal, push each byte to vector expression
                 ast::lit_str(s) => {
-                    for s.each |byte| {
+                    for s.bytes_iter().advance |byte| {
                         bytes.push(cx.expr_u8(sp, byte));
                     }
                 }
diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs
index b36d4496492..078fd4231ca 100644
--- a/src/libsyntax/ext/deriving/generic.rs
+++ b/src/libsyntax/ext/deriving/generic.rs
@@ -1025,11 +1025,11 @@ pub fn cs_fold(use_foldl: bool,
     match *substructure.fields {
         EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
             if use_foldl {
-                do all_fields.foldl(base) |&old, &(_, self_f, other_fs)| {
+                do all_fields.iter().fold(base) |old, &(_, self_f, other_fs)| {
                     f(cx, span, old, self_f, other_fs)
                 }
             } else {
-                do all_fields.foldr(base) |&(_, self_f, other_fs), old| {
+                do all_fields.rev_iter().fold(base) |old, &(_, self_f, other_fs)| {
                     f(cx, span, old, self_f, other_fs)
                 }
             }
@@ -1094,11 +1094,11 @@ pub fn cs_same_method_fold(use_foldl: bool,
     cs_same_method(
         |cx, span, vals| {
             if use_foldl {
-                do vals.foldl(base) |&old, &new| {
+                do vals.iter().fold(base) |old, &new| {
                     f(cx, span, old, new)
                 }
             } else {
-                do vals.foldr(base) |&new, old| {
+                do vals.rev_iter().fold(base) |old, &new| {
                     f(cx, span, old, new)
                 }
             }
diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs
index 13f83b55a40..453d867fce9 100644
--- a/src/libsyntax/ext/deriving/iter_bytes.rs
+++ b/src/libsyntax/ext/deriving/iter_bytes.rs
@@ -16,7 +16,7 @@ use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 
-use core::vec;
+use core::iterator::IteratorUtil;
 
 pub fn expand_deriving_iter_bytes(cx: @ExtCtxt,
                                   span: span,
@@ -85,7 +85,7 @@ fn iter_bytes_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @
         cx.span_bug(span, "#[deriving(IterBytes)] needs at least one field");
     }
 
-    do vec::foldl(exprs[0], exprs.slice(1, exprs.len())) |prev, me| {
+    do exprs.slice(1, exprs.len()).iter().fold(exprs[0]) |prev, me| {
         cx.expr_binary(span, and, prev, *me)
     }
 }
diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs
index 1107f21319c..c091ab8b617 100644
--- a/src/libsyntax/ext/deriving/mod.rs
+++ b/src/libsyntax/ext/deriving/mod.rs
@@ -19,6 +19,7 @@ library.
 */
 
 use core::prelude::*;
+use core::iterator::IteratorUtil;
 
 use ast::{enum_def, ident, item, Generics, meta_item, struct_def};
 use ext::base::ExtCtxt;
@@ -74,7 +75,7 @@ pub fn expand_meta_deriving(cx: @ExtCtxt,
             in_items
         }
         meta_list(_, ref titems) => {
-            do titems.foldr(in_items) |&titem, in_items| {
+            do titems.rev_iter().fold(in_items) |in_items, &titem| {
                 match titem.node {
                     meta_name_value(tname, _) |
                     meta_list(tname, _) |
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index e1f31b83524..1e1f411c050 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -11,11 +11,11 @@
 use core::prelude::*;
 
 use ast::{blk_, attribute_, attr_outer, meta_word};
-use ast::{crate, decl_local, expr_, expr_mac, mac_invoc_tt};
-use ast::{item_mac, local_, stmt_, stmt_decl, stmt_mac, stmt_expr, stmt_semi};
-use ast::{SCTable, illegal_ctxt};
+use ast::{crate, expr_, expr_mac, mac_invoc_tt};
+use ast::{item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
+use ast::{illegal_ctxt};
 use ast;
-use ast_util::{new_rename, new_mark, resolve, get_sctable};
+use ast_util::{new_rename, new_mark, resolve};
 use attr;
 use codemap;
 use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan, spanned};
@@ -23,10 +23,11 @@ use ext::base::*;
 use fold::*;
 use parse;
 use parse::{parse_item_from_source_str};
-use parse::token::{ident_to_str, intern, fresh_name};
+use parse::token::{ident_to_str, intern};
 use visit;
-use visit::{Visitor,mk_vt};
+use visit::Visitor;
 
+use core::iterator::IteratorUtil;
 use core::vec;
 
 pub fn expand_expr(extsbox: @mut SyntaxEnv,
@@ -128,7 +129,7 @@ pub fn expand_mod_items(extsbox: @mut SyntaxEnv,
     // decorated with "item decorators", then use that function to transform
     // the item into a new set of items.
     let new_items = do vec::flat_map(module_.items) |item| {
-        do vec::foldr(item.attrs, ~[*item]) |attr, items| {
+        do item.attrs.rev_iter().fold(~[*item]) |items, attr| {
             let mname = attr::get_attr_name(attr);
 
             match (*extsbox).find(&intern(*mname)) {
@@ -748,16 +749,14 @@ mod test {
     use super::*;
     use ast;
     use ast::{attribute_, attr_outer, meta_word, empty_ctxt};
-    use ast_util::{get_sctable};
     use codemap;
     use codemap::spanned;
     use parse;
-    use parse::token::{gensym, intern, get_ident_interner};
+    use parse::token::{intern, get_ident_interner};
     use print::pprust;
     use util::parser_testing::{string_to_item, string_to_pat, strs_to_idents};
-    use visit::{mk_vt,Visitor};
+    use visit::{mk_vt};
 
-    use core::io;
     use core::option::{None, Some};
 
     // make sure that fail! is present
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 5f43452cc83..a6ec91f899c 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -129,12 +129,12 @@ pub fn copy_up(mpu: &matcher_pos_up) -> ~MatcherPos {
 }
 
 pub fn count_names(ms: &[matcher]) -> uint {
-    vec::foldl(0u, ms, |ct, m| {
+    do ms.iter().fold(0) |ct, m| {
         ct + match m.node {
           match_tok(_) => 0u,
           match_seq(ref more_ms, _, _, _, _) => count_names((*more_ms)),
           match_nonterminal(_,_,_) => 1u
-        }})
+        }}
 }
 
 pub fn initial_matcher_pos(ms: ~[matcher], sep: Option<Token>, lo: BytePos)
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs
index f8a783c568a..f3bd2d4b8d1 100644
--- a/src/libsyntax/ext/tt/transcribe.rs
+++ b/src/libsyntax/ext/tt/transcribe.rs
@@ -19,9 +19,9 @@ use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident};
 use parse::token::{ident_to_str};
 use parse::lexer::TokenAndSpan;
 
+use core::iterator::IteratorUtil;
 use core::hashmap::HashMap;
 use core::option;
-use core::vec;
 
 ///an unzipping of `token_tree`s
 struct TtFrame {
@@ -113,9 +113,7 @@ fn lookup_cur_matched_by_matched(r: &mut TtReader,
           matched_seq(ref ads, _) => ads[*idx]
         }
     }
-    let r = &mut *r;
-    let repeat_idx = &r.repeat_idx;
-    vec::foldl(start, *repeat_idx, red)
+    r.repeat_idx.iter().fold(start, red)
 }
 
 fn lookup_cur_matched(r: &mut TtReader, name: ident) -> @named_match {
@@ -152,10 +150,10 @@ fn lockstep_iter_size(t: &token_tree, r: &mut TtReader) -> lis {
     }
     match *t {
       tt_delim(ref tts) | tt_seq(_, ref tts, _, _) => {
-        vec::foldl(lis_unconstrained, *tts, |lis, tt| {
+        do tts.iter().fold(lis_unconstrained) |lis, tt| {
             let lis2 = lockstep_iter_size(tt, r);
             lis_merge(lis, lis2)
-        })
+        }
       }
       tt_tok(*) => lis_unconstrained,
       tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) {