diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-06-21 08:29:53 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-06-23 02:05:20 -0400 |
| commit | d2e9912aea87f9b1812a0f44e093c0405848f7ce (patch) | |
| tree | a872d8f5ab40841274cbb777c642d3b6c9036a87 /src/libsyntax | |
| parent | c9342663df3e705f6fe380f3d4f46c4a7be8035e (diff) | |
| download | rust-d2e9912aea87f9b1812a0f44e093c0405848f7ce.tar.gz rust-d2e9912aea87f9b1812a0f44e093c0405848f7ce.zip | |
vec: remove BaseIter implementation
I removed the `static-method-test.rs` test because it was heavily based on `BaseIter` and there are plenty of other more complex uses of static methods anyway.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/abi.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ast_map.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/bytes.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/iter_bytes.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/proto.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/opt_vec.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 46 | ||||
| -rw-r--r-- | src/libsyntax/util/interner.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 60 |
21 files changed, 106 insertions, 104 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 943a38a337f..f243bcb0abb 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -87,7 +87,7 @@ fn each_abi(op: &fn(abi: Abi) -> bool) -> bool { * Iterates through each of the defined ABIs. */ - AbiDatas.each(|abi_data| op(abi_data.abi)) + AbiDatas.iter().advance(|abi_data| op(abi_data.abi)) } pub fn lookup(name: &str) -> Option<Abi> { @@ -213,7 +213,7 @@ impl AbiSet { for abis.iter().enumerate().advance |(i, abi)| { let data = abi.data(); - for abis.slice(0, i).each |other_abi| { + for abis.slice(0, i).iter().advance |other_abi| { let other_data = other_abi.data(); debug!("abis=(%?,%?) datas=(%?,%?)", abi, data.abi_arch, @@ -389,7 +389,7 @@ fn indices_are_correct() { #[cfg(test)] fn check_arch(abis: &[Abi], arch: Architecture, expect: Option<Abi>) { let mut set = AbiSet::empty(); - for abis.each |&abi| { + for abis.iter().advance |&abi| { set.add(abi); } let r = set.for_arch(arch); diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index a7c29e8a869..a0e1ec69350 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -185,7 +185,7 @@ pub fn map_fn( (cx,v): (@mut Ctx, visit::vt<@mut Ctx>) ) { - for decl.inputs.each |a| { + for decl.inputs.iter().advance |a| { cx.map.insert(a.id, node_arg); } visit::visit_fn(fk, decl, body, sp, id, (cx, v)); @@ -220,19 +220,19 @@ pub fn map_item(i: @item, (cx, v): (@mut Ctx, visit::vt<@mut Ctx>)) { match i.node { item_impl(_, _, _, ref ms) => { let impl_did = ast_util::local_def(i.id); - for ms.each |m| { + for ms.iter().advance |m| { map_method(impl_did, extend(cx, i.ident), *m, cx); } } item_enum(ref enum_definition, _) => { - for (*enum_definition).variants.each |v| { + for (*enum_definition).variants.iter().advance |v| { cx.map.insert(v.node.id, node_variant( /* FIXME (#2543) */ copy *v, i, extend(cx, i.ident))); } } item_foreign_mod(ref nm) => { - for nm.items.each |nitem| { + for nm.items.iter().advance |nitem| { // Compute the visibility for this native item. let visibility = match nitem.vis { public => public, @@ -266,10 +266,10 @@ pub fn map_item(i: @item, (cx, v): (@mut Ctx, visit::vt<@mut Ctx>)) { ); } item_trait(_, ref traits, ref methods) => { - for traits.each |p| { + for traits.iter().advance |p| { cx.map.insert(p.ref_id, node_item(i, item_path)); } - for methods.each |tm| { + for methods.iter().advance |tm| { let id = ast_util::trait_method_to_ty_method(tm).id; let d_id = ast_util::local_def(i.id); cx.map.insert( diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index a4ded8fea8c..34c247662a4 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -281,7 +281,7 @@ pub fn split_trait_methods(trait_methods: &[trait_method]) -> (~[ty_method], ~[@method]) { let mut reqd = ~[]; let mut provd = ~[]; - for trait_methods.each |trt_method| { + for trait_methods.iter().advance |trt_method| { match *trt_method { required(ref tm) => reqd.push(copy *tm), provided(m) => provd.push(m) @@ -411,13 +411,13 @@ pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> { match vi.node { view_item_extern_mod(_, _, id) => vfn(id, copy t), view_item_use(ref vps) => { - for vps.each |vp| { + for vps.iter().advance |vp| { match vp.node { view_path_simple(_, _, id) => vfn(id, copy t), view_path_glob(_, id) => vfn(id, copy t), view_path_list(_, ref paths, id) => { vfn(id, copy t); - for paths.each |p| { + for paths.iter().advance |p| { vfn(p.node.id, copy t); } } @@ -437,7 +437,7 @@ pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> { vfn(i.id, copy t); match i.node { item_enum(ref enum_definition, _) => - for (*enum_definition).variants.each |v| { vfn(v.node.id, copy t); }, + for (*enum_definition).variants.iter().advance |v| { vfn(v.node.id, copy t); }, _ => () } visit::visit_item(i, (t, vt)); @@ -500,7 +500,7 @@ pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> { } } - for d.inputs.each |arg| { + for d.inputs.iter().advance |arg| { vfn(arg.id, copy t) } visit::visit_fn(fk, d, a, b, id, (copy t, vt)); @@ -546,16 +546,16 @@ pub fn walk_pat(pat: @pat, it: &fn(@pat) -> bool) -> bool { match pat.node { pat_ident(_, _, Some(p)) => walk_pat(p, it), pat_struct(_, ref fields, _) => { - fields.each(|f| walk_pat(f.pat, it)) + fields.iter().advance(|f| walk_pat(f.pat, it)) } pat_enum(_, Some(ref s)) | pat_tup(ref s) => { - s.each(|&p| walk_pat(p, it)) + s.iter().advance(|&p| walk_pat(p, it)) } pat_box(s) | pat_uniq(s) | pat_region(s) => { walk_pat(s, it) } pat_vec(ref before, ref slice, ref after) => { - before.each(|&p| walk_pat(p, it)) && + before.iter().advance(|&p| walk_pat(p, it)) && slice.iter().advance(|&p| walk_pat(p, it)) && after.iter().advance(|&p| walk_pat(p, it)) } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 96e05fd2beb..d9fb91e6ddd 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -158,7 +158,7 @@ pub fn find_attrs_by_name(attrs: &[ast::attribute], name: &str) -> pub fn find_meta_items_by_name(metas: &[@ast::meta_item], name: &str) -> ~[@ast::meta_item] { let mut rs = ~[]; - for metas.each |mi| { + for metas.iter().advance |mi| { if name == get_meta_item_name(*mi) { rs.push(*mi) } @@ -172,7 +172,7 @@ pub fn find_meta_items_by_name(metas: &[@ast::meta_item], name: &str) -> */ pub fn contains(haystack: &[@ast::meta_item], needle: @ast::meta_item) -> bool { - for haystack.each |item| { + for haystack.iter().advance |item| { if eq(*item, needle) { return true; } } return false; @@ -193,7 +193,7 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool { ast::meta_list(ref na, ref misa) => match b.node { ast::meta_list(ref nb, ref misb) => { if na != nb { return false; } - for misa.each |mi| { + for misa.iter().advance |mi| { if !misb.iter().any_(|x| x == mi) { return false; } } true @@ -334,7 +334,7 @@ pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { pub fn require_unique_names(diagnostic: @span_handler, metas: &[@ast::meta_item]) { let mut set = HashSet::new(); - for metas.each |meta| { + for metas.iter().advance |meta| { let name = get_meta_item_name(*meta); // FIXME: How do I silence the warnings? --pcw (#2619) diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 0c09a001d48..bae5e943a48 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -422,7 +422,7 @@ impl CodeMap { } pub fn get_filemap(&self, filename: &str) -> @FileMap { - for self.files.each |fm| { if filename == fm.name { return *fm; } } + for self.files.iter().advance |fm| { if filename == fm.name { return *fm; } } //XXjdm the following triggers a mismatched type bug // (or expected function, found _|_) fail!(); // ("asking for " + filename + " which we don't know about"); @@ -508,7 +508,7 @@ impl CodeMap { // The number of extra bytes due to multibyte chars in the FileMap let mut total_extra_bytes = 0; - for map.multibyte_chars.each |mbc| { + for map.multibyte_chars.iter().advance |mbc| { debug!("codemap: %?-byte char at %?", mbc.bytes, mbc.pos); if mbc.pos < bpos { total_extra_bytes += mbc.bytes; diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index c0a23593f85..7b4ed19fe7f 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -256,7 +256,7 @@ fn highlight_lines(cm: @codemap::CodeMap, elided = true; } // Print the offending lines - for display_lines.each |line| { + for display_lines.iter().advance |line| { io::stderr().write_str(fmt!("%s:%u ", fm.name, *line + 1u)); let s = fm.get_line(*line as int) + "\n"; io::stderr().write_str(s); diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index 59a9ec407b0..3f64654dd80 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -21,7 +21,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> bas let exprs = get_exprs_from_tts(cx, tts); let mut bytes = ~[]; - for exprs.each |expr| { + for exprs.iter().advance |expr| { match expr.node { // expression is a literal ast::expr_lit(lit) => match lit.node { diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index d44d4668299..dca1b7bbd59 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -286,7 +286,7 @@ impl<'self> TraitDef<'self> { _mitem: @ast::meta_item, in_items: ~[@ast::item]) -> ~[@ast::item] { let mut result = ~[]; - for in_items.each |item| { + for in_items.iter().advance |item| { result.push(*item); match item.node { ast::item_struct(struct_def, ref generics) => { @@ -740,7 +740,7 @@ impl<'self> MethodDef<'self> { let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]); - for matches_so_far.tail().each |&(_, _, other_fields)| { + for matches_so_far.tail().iter().advance |&(_, _, other_fields)| { for other_fields.iter().enumerate().advance |(i, &(_, other_field))| { enum_matching_fields[i].push(other_field); } @@ -870,7 +870,7 @@ fn summarise_struct(cx: @ExtCtxt, span: span, struct_def: &struct_def) -> Either<uint, ~[ident]> { let mut named_idents = ~[]; let mut unnamed_count = 0; - for struct_def.fields.each |field| { + for struct_def.fields.iter().advance |field| { match field.node.kind { ast::named_field(ident, _) => named_idents.push(ident), ast::unnamed_field => unnamed_count += 1, diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs index 83cff70d459..c7949f9a8e3 100644 --- a/src/libsyntax/ext/deriving/iter_bytes.rs +++ b/src/libsyntax/ext/deriving/iter_bytes.rs @@ -76,7 +76,7 @@ fn iter_bytes_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @ _ => cx.span_bug(span, "Impossible substructure in `deriving(IterBytes)`") } - for fields.each |&(_, field, _)| { + for fields.iter().advance |&(_, field, _)| { exprs.push(call_iterbytes(field)); } diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 4425d54987c..4c0a85b665a 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -70,7 +70,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span, fn make_rt_conv_expr(cx: @ExtCtxt, sp: span, cnv: &Conv) -> @ast::expr { fn make_flags(cx: @ExtCtxt, sp: span, flags: &[Flag]) -> @ast::expr { let mut tmp_expr = make_rt_path_expr(cx, sp, "flag_none"); - for flags.each |f| { + for flags.iter().advance |f| { let fstr = match *f { FlagLeftJustify => "flag_left_justify", FlagLeftZeroPad => "flag_left_zero_pad", @@ -156,7 +156,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span, option::None => (), _ => cx.span_unimpl(sp, unsupported) } - for cnv.flags.each |f| { + for cnv.flags.iter().advance |f| { match *f { FlagLeftJustify => (), FlagSignAlways => { @@ -205,7 +205,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span, Some(p) => { debug!("param: %s", p.to_str()); } _ => debug!("param: none") } - for c.flags.each |f| { + for c.flags.iter().advance |f| { match *f { FlagLeftJustify => debug!("flag: left justify"), FlagLeftZeroPad => debug!("flag: left zero pad"), diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 083386fe720..8478a827e85 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -209,7 +209,7 @@ impl to_type_decls for state { let mut items_msg = ~[]; - for self.messages.each |m| { + for self.messages.iter().advance |m| { let message(name, span, tys, this, next) = copy *m; let tys = match next { @@ -372,7 +372,7 @@ impl gen_init for protocol { fn buffer_ty_path(&self, cx: @ExtCtxt) -> @ast::Ty { let mut params: OptVec<ast::TyParam> = opt_vec::Empty; - for (copy self.states).each |s| { + for (copy self.states).iter().advance |s| { for s.generics.ty_params.each |tp| { match params.find(|tpp| tp.ident == tpp.ident) { None => params.push(*tp), @@ -433,7 +433,7 @@ impl gen_init for protocol { let mut client_states = ~[]; let mut server_states = ~[]; - for (copy self.states).each |s| { + for (copy self.states).iter().advance |s| { items += s.to_type_decls(cx); client_states += s.to_endpoint_decls(cx, send); diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 3df19ed0a76..d00f1fd7746 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -107,7 +107,7 @@ impl state_ { /// Iterate over the states that can be reached in one message /// from this state. pub fn reachable(&self, f: &fn(state) -> bool) -> bool { - for self.messages.each |m| { + for self.messages.iter().advance |m| { match *m { message(_, _, _, _, Some(next_state { state: ref id, _ })) => { let state = self.proto.get_state((*id)); @@ -165,7 +165,7 @@ impl protocol_ { } pub fn has_ty_params(&self) -> bool { - for self.states.each |s| { + for self.states.iter().advance |s| { if s.generics.ty_params.len() > 0 { return true; } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 44e480dc7df..742f5a97825 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -637,7 +637,7 @@ fn mk_tt(cx: @ExtCtxt, sp: span, tt: &ast::token_tree) fn mk_tts(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> ~[@ast::stmt] { let mut ss = ~[]; - for tts.each |tt| { + for tts.iter().advance |tt| { ss.push_all_move(mk_tt(cx, sp, tt)); } ss diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 3fb94bbce38..f2b57db06c1 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -138,7 +138,7 @@ pub fn count_names(ms: &[matcher]) -> uint { pub fn initial_matcher_pos(ms: ~[matcher], sep: Option<Token>, lo: BytePos) -> ~MatcherPos { let mut match_idx_hi = 0u; - for ms.each |elt| { + for ms.iter().advance |elt| { match elt.node { match_tok(_) => (), match_seq(_,_,_,_,hi) => { @@ -195,7 +195,7 @@ pub fn nameize(p_s: @mut ParseSess, ms: &[matcher], res: &[@named_match]) match *m { codemap::spanned {node: match_tok(_), _} => (), codemap::spanned {node: match_seq(ref more_ms, _, _, _, _), _} => { - for more_ms.each |next_m| { + for more_ms.iter().advance |next_m| { n_rec(p_s, next_m, res, ret_val) }; } @@ -211,8 +211,8 @@ pub fn nameize(p_s: @mut ParseSess, ms: &[matcher], res: &[@named_match]) } } let mut ret_val = HashMap::new(); - for ms.each |m| { n_rec(p_s, m, res, &mut ret_val) } - return ret_val; + for ms.iter().advance |m| { n_rec(p_s, m, res, &mut ret_val) } + ret_val } pub enum parse_result { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index c1bf979cd31..568324bc599 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -378,7 +378,7 @@ fn noop_fold_method(m: @method, fld: @ast_fold) -> @method { pub fn noop_fold_block(b: &blk_, fld: @ast_fold) -> blk_ { let view_items = b.view_items.map(|x| fld.fold_view_item(*x)); let mut stmts = ~[]; - for b.stmts.each |stmt| { + for b.stmts.iter().advance |stmt| { match fld.fold_stmt(*stmt) { None => {} Some(stmt) => stmts.push(stmt) diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 81f540fd69f..c537a3e8eba 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -135,7 +135,7 @@ impl<A> BaseIter<A> for OptVec<A> { fn each(&self, blk: &fn(v: &A) -> bool) -> bool { match *self { Empty => true, - Vec(ref v) => v.each(blk) + Vec(ref v) => v.iter().advance(blk) } } diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index ccc1cbd0d89..84915b6403a 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -835,7 +835,7 @@ mod test { // check that the given reader produces the desired stream // of tokens (stop checking after exhausting the expected vec) fn check_tokenization (env: Env, expected: ~[token::Token]) { - for expected.each |expected_tok| { + for expected.iter().advance |expected_tok| { let TokenAndSpan {tok:actual_tok, sp: _} = env.string_reader.next_token(); assert_eq!(&actual_tok,expected_tok); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4e52b6b7367..753c69b23d6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2746,7 +2746,7 @@ impl Parser { } = self.parse_items_and_view_items(first_item_attrs, false, false); - for items.each |item| { + for items.iter().advance |item| { let decl = @spanned(item.span.lo, item.span.hi, decl_item(*item)); stmts.push(@spanned(item.span.lo, item.span.hi, stmt_decl(decl, self.get_id()))); @@ -3356,7 +3356,8 @@ impl Parser { is_tuple_like = false; fields = ~[]; while *self.token != token::RBRACE { - for self.parse_struct_decl_field().each |struct_field| { + let r = self.parse_struct_decl_field(); + for r.iter().advance |struct_field| { fields.push(*struct_field) } } @@ -3825,7 +3826,8 @@ impl Parser { fn parse_struct_def(&self) -> @struct_def { let mut fields: ~[@struct_field] = ~[]; while *self.token != token::RBRACE { - for self.parse_struct_decl_field().each |struct_field| { + let r = self.parse_struct_decl_field(); + for r.iter().advance |struct_field| { fields.push(*struct_field); } } @@ -3865,7 +3867,7 @@ impl Parser { seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_ty(false) ); - for arg_tys.each |ty| { + for arg_tys.iter().advance |ty| { args.push(ast::variant_arg { ty: *ty, id: self.get_id(), diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d73c5240a1c..8e47df51010 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -320,7 +320,7 @@ pub fn synth_comment(s: @ps, text: ~str) { pub fn commasep<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) { box(s, 0u, b); let mut first = true; - for elts.each |elt| { + for elts.iter().advance |elt| { if first { first = false; } else { word_space(s, ","); } op(s, copy *elt); } @@ -333,7 +333,7 @@ pub fn commasep_cmnt<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN), box(s, 0u, b); let len = elts.len(); let mut i = 0u; - for elts.each |elt| { + for elts.iter().advance |elt| { maybe_print_comment(s, get_span(copy *elt).hi); op(s, copy *elt); i += 1u; @@ -354,19 +354,19 @@ pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) { pub fn print_mod(s: @ps, _mod: &ast::_mod, attrs: &[ast::attribute]) { print_inner_attributes(s, attrs); - for _mod.view_items.each |vitem| { + for _mod.view_items.iter().advance |vitem| { print_view_item(s, *vitem); } - for _mod.items.each |item| { print_item(s, *item); } + for _mod.items.iter().advance |item| { print_item(s, *item); } } pub fn print_foreign_mod(s: @ps, nmod: &ast::foreign_mod, attrs: &[ast::attribute]) { print_inner_attributes(s, attrs); - for nmod.view_items.each |vitem| { + for nmod.view_items.iter().advance |vitem| { print_view_item(s, *vitem); } - for nmod.items.each |item| { print_foreign_item(s, *item); } + for nmod.items.iter().advance |item| { print_foreign_item(s, *item); } } pub fn print_opt_lifetime(s: @ps, lifetime: Option<@ast::Lifetime>) { @@ -580,7 +580,7 @@ pub fn print_item(s: @ps, item: @ast::item) { word(s.s, ";"); } else { bopen(s); - for methods.each |meth| { + for methods.iter().advance |meth| { print_method(s, *meth); } bclose(s, item.span); @@ -602,7 +602,7 @@ pub fn print_item(s: @ps, item: @ast::item) { } word(s.s, " "); bopen(s); - for methods.each |meth| { + for methods.iter().advance |meth| { print_trait_method(s, meth); } bclose(s, item.span); @@ -641,7 +641,7 @@ pub fn print_variants(s: @ps, variants: &[ast::variant], span: codemap::span) { bopen(s); - for variants.each |v| { + for variants.iter().advance |v| { space_if_not_bol(s); maybe_print_comment(s, v.span.lo); print_outer_attributes(s, v.node.attrs); @@ -706,7 +706,7 @@ pub fn print_struct(s: @ps, bopen(s); hardbreak_if_not_bol(s); - for struct_def.fields.each |field| { + for struct_def.fields.iter().advance |field| { match field.node.kind { ast::unnamed_field => fail!("unexpected unnamed field"), ast::named_field(ident, visibility) => { @@ -741,7 +741,7 @@ pub fn print_tt(s: @ps, tt: &ast::token_tree) { } ast::tt_seq(_, ref tts, ref sep, zerok) => { word(s.s, "$("); - for (*tts).each() |tt_elt| { print_tt(s, tt_elt); } + for (*tts).iter().advance |tt_elt| { print_tt(s, tt_elt); } word(s.s, ")"); match (*sep) { Some(ref tk) => word(s.s, parse::token::to_str(s.intr, tk)), @@ -827,7 +827,7 @@ pub fn print_method(s: @ps, meth: @ast::method) { pub fn print_outer_attributes(s: @ps, attrs: &[ast::attribute]) { let mut count = 0; - for attrs.each |attr| { + for attrs.iter().advance |attr| { match attr.node.style { ast::attr_outer => { print_attribute(s, *attr); count += 1; } _ => {/* fallthrough */ } @@ -838,7 +838,7 @@ pub fn print_outer_attributes(s: @ps, attrs: &[ast::attribute]) { pub fn print_inner_attributes(s: @ps, attrs: &[ast::attribute]) { let mut count = 0; - for attrs.each |attr| { + for attrs.iter().advance |attr| { match attr.node.style { ast::attr_inner => { print_attribute(s, *attr); @@ -944,8 +944,8 @@ pub fn print_possibly_embedded_block_(s: @ps, print_inner_attributes(s, attrs); - for blk.node.view_items.each |vi| { print_view_item(s, *vi); } - for blk.node.stmts.each |st| { + for blk.node.view_items.iter().advance |vi| { print_view_item(s, *vi); } + for blk.node.stmts.iter().advance |st| { print_stmt(s, *st); } match blk.node.expr { @@ -1234,7 +1234,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) { cbox(s, indent_unit); ibox(s, 0u); let mut first = true; - for arm.pats.each |p| { + for arm.pats.iter().advance |p| { if first { first = false; } else { space(s.s); word_space(s, "|"); } @@ -1401,7 +1401,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) { popen(s); print_string(s, a.asm); word_space(s, ":"); - for a.outputs.each |&(co, o)| { + for a.outputs.iter().advance |&(co, o)| { print_string(s, co); popen(s); print_expr(s, o); @@ -1409,7 +1409,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) { word_space(s, ","); } word_space(s, ":"); - for a.inputs.each |&(co, o)| { + for a.inputs.iter().advance |&(co, o)| { print_string(s, co); popen(s); print_expr(s, o); @@ -1487,7 +1487,7 @@ pub fn print_path(s: @ps, path: @ast::Path, colons_before_params: bool) { maybe_print_comment(s, path.span.lo); if path.global { word(s.s, "::"); } let mut first = true; - for path.idents.each |id| { + for path.idents.iter().advance |id| { if first { first = false; } else { word(s.s, "::"); } print_ident(s, *id); } @@ -1678,7 +1678,7 @@ pub fn print_fn_args(s: @ps, decl: &ast::fn_decl, first = !print_explicit_self(s, *explicit_self); } - for decl.inputs.each |arg| { + for decl.inputs.iter().advance |arg| { if first { first = false; } else { word_space(s, ","); } print_arg(s, *arg); } @@ -1924,7 +1924,7 @@ pub fn print_ty_fn(s: @ps, for opt_explicit_self.iter().advance |explicit_self| { first = !print_explicit_self(s, *explicit_self); } - for decl.inputs.each |arg| { + for decl.inputs.iter().advance |arg| { if first { first = false; } else { word_space(s, ","); } print_arg(s, *arg); } @@ -2075,7 +2075,7 @@ pub fn print_comment(s: @ps, cmnt: &comments::cmnt) { } comments::isolated => { pprust::hardbreak_if_not_bol(s); - for cmnt.lines.each |line| { + for cmnt.lines.iter().advance |line| { // Don't print empty lines because they will end up as trailing // whitespace if !line.is_empty() { word(s.s, *line); } @@ -2089,7 +2089,7 @@ pub fn print_comment(s: @ps, cmnt: &comments::cmnt) { hardbreak(s.s); } else { ibox(s, 0u); - for cmnt.lines.each |line| { + for cmnt.lines.iter().advance |line| { if !line.is_empty() { word(s.s, *line); } hardbreak(s.s); } diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index bd5c178e7fe..004ba7762d3 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -36,7 +36,7 @@ impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> { pub fn prefill(init: &[T]) -> Interner<T> { let rv = Interner::new(); - for init.each() |v| { rv.intern(copy *v); } + for init.iter().advance |v| { rv.intern(copy *v); } rv } @@ -94,7 +94,7 @@ impl StrInterner { pub fn prefill(init: &[&str]) -> StrInterner { let rv = StrInterner::new(); - for init.each |&v| { rv.intern(v); } + for init.iter().advance |&v| { rv.intern(v); } rv } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index f24c393d7b4..e7afeb12a61 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -127,8 +127,8 @@ pub fn visit_crate<E: Copy>(c: &crate, (e, v): (E, vt<E>)) { } pub fn visit_mod<E: Copy>(m: &_mod, _sp: span, _id: node_id, (e, v): (E, vt<E>)) { - for m.view_items.each |vi| { (v.visit_view_item)(*vi, (copy e, v)); } - for m.items.each |i| { (v.visit_item)(*i, (copy e, v)); } + for m.view_items.iter().advance |vi| { (v.visit_view_item)(*vi, (copy e, v)); } + for m.items.iter().advance |i| { (v.visit_item)(*i, (copy e, v)); } } pub fn visit_view_item<E>(_vi: @view_item, (_e, _v): (E, vt<E>)) { } @@ -170,8 +170,8 @@ pub fn visit_item<E: Copy>(i: @item, (e, v): (E, vt<E>)) { } item_mod(ref m) => (v.visit_mod)(m, i.span, i.id, (e, v)), item_foreign_mod(ref nm) => { - for nm.view_items.each |vi| { (v.visit_view_item)(*vi, (copy e, v)); } - for nm.items.each |ni| { (v.visit_foreign_item)(*ni, (copy e, v)); } + for nm.view_items.iter().advance |vi| { (v.visit_view_item)(*vi, (copy e, v)); } + for nm.items.iter().advance |ni| { (v.visit_foreign_item)(*ni, (copy e, v)); } } item_ty(t, ref tps) => { (v.visit_ty)(t, (copy e, v)); @@ -191,7 +191,7 @@ pub fn visit_item<E: Copy>(i: @item, (e, v): (E, vt<E>)) { visit_trait_ref(p, (copy e, v)); } (v.visit_ty)(ty, (copy e, v)); - for methods.each |m| { + for methods.iter().advance |m| { visit_method_helper(*m, (copy e, v)) } } @@ -201,8 +201,8 @@ pub fn visit_item<E: Copy>(i: @item, (e, v): (E, vt<E>)) { } item_trait(ref generics, ref traits, ref methods) => { (v.visit_generics)(generics, (copy e, v)); - for traits.each |p| { visit_path(p.path, (copy e, v)); } - for methods.each |m| { + for traits.iter().advance |p| { visit_path(p.path, (copy e, v)); } + for methods.iter().advance |m| { (v.visit_trait_method)(m, (copy e, v)); } } @@ -213,10 +213,10 @@ pub fn visit_item<E: Copy>(i: @item, (e, v): (E, vt<E>)) { pub fn visit_enum_def<E: Copy>(enum_definition: &ast::enum_def, tps: &Generics, (e, v): (E, vt<E>)) { - for enum_definition.variants.each |vr| { + for enum_definition.variants.iter().advance |vr| { match vr.node.kind { tuple_variant_kind(ref variant_args) => { - for variant_args.each |va| { + for variant_args.iter().advance |va| { (v.visit_ty)(va.ty, (copy e, v)); } } @@ -241,16 +241,16 @@ pub fn visit_ty<E: Copy>(t: @Ty, (e, v): (E, vt<E>)) { (v.visit_ty)(mt.ty, (e, v)); }, ty_tup(ref ts) => { - for ts.each |tt| { + for ts.iter().advance |tt| { (v.visit_ty)(*tt, (copy e, v)); } }, ty_closure(ref f) => { - for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, (copy e, v)); } + for f.decl.inputs.iter().advance |a| { (v.visit_ty)(a.ty, (copy e, v)); } (v.visit_ty)(f.decl.output, (e, v)); }, ty_bare_fn(ref f) => { - for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, (copy e, v)); } + for f.decl.inputs.iter().advance |a| { (v.visit_ty)(a.ty, (copy e, v)); } (v.visit_ty)(f.decl.output, (e, v)); }, ty_path(p, _) => visit_path(p, (e, v)), @@ -263,7 +263,7 @@ pub fn visit_ty<E: Copy>(t: @Ty, (e, v): (E, vt<E>)) { } pub fn visit_path<E: Copy>(p: @Path, (e, v): (E, vt<E>)) { - for p.types.each |tp| { (v.visit_ty)(*tp, (copy e, v)); } + for p.types.iter().advance |tp| { (v.visit_ty)(*tp, (copy e, v)); } } pub fn visit_pat<E: Copy>(p: @pat, (e, v): (E, vt<E>)) { @@ -278,12 +278,12 @@ pub fn visit_pat<E: Copy>(p: @pat, (e, v): (E, vt<E>)) { } pat_struct(path, ref fields, _) => { visit_path(path, (copy e, v)); - for fields.each |f| { + for fields.iter().advance |f| { (v.visit_pat)(f.pat, (copy e, v)); } } pat_tup(ref elts) => { - for elts.each |elt| { + for elts.iter().advance |elt| { (v.visit_pat)(*elt, (copy e, v)) } }, @@ -303,13 +303,13 @@ pub fn visit_pat<E: Copy>(p: @pat, (e, v): (E, vt<E>)) { } pat_wild => (), pat_vec(ref before, ref slice, ref after) => { - for before.each |elt| { + for before.iter().advance |elt| { (v.visit_pat)(*elt, (copy e, v)); } for slice.iter().advance |elt| { (v.visit_pat)(*elt, (copy e, v)); } - for after.each |tail| { + for after.iter().advance |tail| { (v.visit_pat)(*tail, (copy e, v)); } } @@ -345,7 +345,7 @@ pub fn visit_generics<E: Copy>(generics: &Generics, (e, v): (E, vt<E>)) { } pub fn visit_fn_decl<E: Copy>(fd: &fn_decl, (e, v): (E, vt<E>)) { - for fd.inputs.each |a| { + for fd.inputs.iter().advance |a| { (v.visit_pat)(a.pat, (copy e, v)); (v.visit_ty)(a.ty, (copy e, v)); } @@ -380,7 +380,7 @@ pub fn visit_fn<E: Copy>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span, } pub fn visit_ty_method<E: Copy>(m: &ty_method, (e, v): (E, vt<E>)) { - for m.decl.inputs.each |a| { (v.visit_ty)(a.ty, (copy e, v)); } + for m.decl.inputs.iter().advance |a| { (v.visit_ty)(a.ty, (copy e, v)); } (v.visit_generics)(&m.generics, (copy e, v)); (v.visit_ty)(m.decl.output, (e, v)); } @@ -399,7 +399,7 @@ pub fn visit_struct_def<E: Copy>( _id: node_id, (e, v): (E, vt<E>) ) { - for sd.fields.each |f| { + for sd.fields.iter().advance |f| { (v.visit_struct_field)(*f, (copy e, v)); } } @@ -413,10 +413,10 @@ pub fn visit_struct_method<E: Copy>(m: @method, (e, v): (E, vt<E>)) { } pub fn visit_block<E: Copy>(b: &blk, (e, v): (E, vt<E>)) { - for b.node.view_items.each |vi| { + for b.node.view_items.iter().advance |vi| { (v.visit_view_item)(*vi, (copy e, v)); } - for b.node.stmts.each |s| { + for b.node.stmts.iter().advance |s| { (v.visit_stmt)(*s, (copy e, v)); } visit_expr_opt(b.node.expr, (e, v)); @@ -443,7 +443,7 @@ pub fn visit_expr_opt<E>(eo: Option<@expr>, (e, v): (E, vt<E>)) { } pub fn visit_exprs<E: Copy>(exprs: &[@expr], (e, v): (E, vt<E>)) { - for exprs.each |ex| { (v.visit_expr)(*ex, (copy e, v)); } + for exprs.iter().advance |ex| { (v.visit_expr)(*ex, (copy e, v)); } } pub fn visit_mac<E>(_m: &mac, (_e, _v): (E, vt<E>)) { @@ -460,13 +460,13 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) { } expr_struct(p, ref flds, base) => { visit_path(p, (copy e, v)); - for flds.each |f| { + for flds.iter().advance |f| { (v.visit_expr)(f.node.expr, (copy e, v)); } visit_expr_opt(base, (copy e, v)); } expr_tup(ref elts) => { - for elts.each |el| { (v.visit_expr)(*el, (copy e, v)) } + for elts.iter().advance |el| { (v.visit_expr)(*el, (copy e, v)) } } expr_call(callee, ref args, _) => { visit_exprs(*args, (copy e, v)); @@ -474,7 +474,7 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) { } expr_method_call(_, callee, _, ref tys, ref args, _) => { visit_exprs(*args, (copy e, v)); - for tys.each |tp| { + for tys.iter().advance |tp| { (v.visit_ty)(*tp, (copy e, v)); } (v.visit_expr)(callee, (copy e, v)); @@ -502,7 +502,7 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) { expr_loop(ref b, _) => (v.visit_block)(b, (copy e, v)), expr_match(x, ref arms) => { (v.visit_expr)(x, (copy e, v)); - for arms.each |a| { (v.visit_arm)(a, (copy e, v)); } + for arms.iter().advance |a| { (v.visit_arm)(a, (copy e, v)); } } expr_fn_block(ref decl, ref body) => { (v.visit_fn)( @@ -526,7 +526,7 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) { } expr_field(x, _, ref tys) => { (v.visit_expr)(x, (copy e, v)); - for tys.each |tp| { + for tys.iter().advance |tp| { (v.visit_ty)(*tp, (copy e, v)); } } @@ -546,10 +546,10 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) { expr_mac(ref mac) => visit_mac(mac, (copy e, v)), expr_paren(x) => (v.visit_expr)(x, (copy e, v)), expr_inline_asm(ref a) => { - for a.inputs.each |&(_, in)| { + for a.inputs.iter().advance |&(_, in)| { (v.visit_expr)(in, (copy e, v)); } - for a.outputs.each |&(_, out)| { + for a.outputs.iter().advance |&(_, out)| { (v.visit_expr)(out, (copy e, v)); } } |
