diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/bytes.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/iter_bytes.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/mod.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 21 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 1 |
13 files changed, 36 insertions, 37 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 5bbc5d4e819..f27ae3b828c 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -15,7 +15,7 @@ use core::prelude::*; use codemap::{span, spanned}; use abi::AbiSet; use opt_vec::OptVec; -use parse::token::{ident_to_str, interner_get, str_to_ident}; +use parse::token::{interner_get, str_to_ident}; use core::hashmap::HashMap; use core::option::Option; diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index d99363d7ee5..b040397de72 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -792,6 +792,7 @@ mod test { use ast::*; use super::*; use core::io; + use core::iterator::IteratorUtil; #[test] fn xorpush_test () { let mut s = ~[]; @@ -833,7 +834,7 @@ mod test { // returning the resulting index fn unfold_test_sc(tscs : ~[TestSC], tail: SyntaxContext, table : &mut SCTable) -> SyntaxContext { - tscs.foldr(tail, |tsc : &TestSC,tail : SyntaxContext| + tscs.rev_iter().fold(tail, |tail : SyntaxContext, tsc : &TestSC| {match *tsc { M(mrk) => new_mark_internal(mrk,tail,table), R(ident,name) => new_rename_internal(ident,name,tail,table)}}) @@ -874,7 +875,7 @@ mod test { // extend a syntax context with a sequence of marks given // in a vector. v[0] will be the outermost mark. fn unfold_marks(mrks:~[Mrk],tail:SyntaxContext,table: &mut SCTable) -> SyntaxContext { - mrks.foldr(tail, |mrk:&Mrk,tail:SyntaxContext| + mrks.rev_iter().fold(tail, |tail:SyntaxContext, mrk:&Mrk| {new_mark_internal(*mrk,tail,table)}) } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 2da64563159..51334772c84 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -19,6 +19,7 @@ use codemap::BytePos; use diagnostic::span_handler; use parse::comments::{doc_comment_style, strip_doc_comment_decoration}; +use core::iterator::IteratorUtil; use core::hashmap::HashSet; use core::vec; use extra; @@ -313,7 +314,7 @@ pub enum inline_attr { /// True if something like #[inline] is found in the list of attrs. pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { // FIXME (#2809)---validate the usage of #[inline] and #[inline(always)] - do vec::foldl(ia_none, attrs) |ia,attr| { + do attrs.iter().fold(ia_none) |ia,attr| { match attr.node.value.node { ast::meta_word(@~"inline") => ia_hint, ast::meta_list(@~"inline", ref items) => { 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) { diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 54fba29a19a..360ea12ec02 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -19,8 +19,8 @@ use parse::lexer::{is_line_non_doc_comment, is_block_non_doc_comment}; use parse::lexer; use parse::token; use parse::token::{get_ident_interner}; -use parse; +use core::iterator::IteratorUtil; use core::io; use core::str; use core::uint; @@ -78,7 +78,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str { if line.trim().is_empty() { loop; } - for line.each_chari |j, c| { + for line.iter().enumerate().advance |(j, c)| { if j >= i { break; } @@ -91,7 +91,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str { return do lines.map |line| { let mut chars = ~[]; - for str::each_char(*line) |c| { chars.push(c) } + for line.iter().advance |c| { chars.push(c) } if i > chars.len() { ~"" } else { diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index d7248204e1c..559bca34f21 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -341,10 +341,9 @@ mod test { use codemap::{span, BytePos, spanned}; use opt_vec; use ast; - use ast::{new_ident}; use abi; use parse::parser::Parser; - use parse::token::{intern, str_to_ident}; + use parse::token::{str_to_ident}; use util::parser_testing::{string_to_tts_and_sess, string_to_parser}; use util::parser_testing::{string_to_expr, string_to_item}; use util::parser_testing::{string_to_stmt, strs_to_idents}; diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index ecf83483c21..7359448a8f2 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -22,7 +22,6 @@ use core::char; use core::cmp::Equiv; use core::local_data; use core::str; -use core::hashmap::HashSet; use core::rand; use core::rand::RngUtil; use core::to_bytes; |
