diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_util.rs | 22 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/clone.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/default.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 34 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/rand.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/ty.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/zero.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 104 | ||||
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/util/parser_testing.rs | 2 |
15 files changed, 117 insertions, 111 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 3dbd10b625c..1676a130235 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -25,9 +25,9 @@ use std::u32; pub fn path_name_i(idents: &[Ident]) -> ~str { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") - idents.map(|i| { + idents.iter().map(|i| { token::get_ident(*i).get().to_str() - }).connect("::") + }).collect::<Vec<~str>>().connect("::") } // totally scary function: ignores all but the last element, should have @@ -717,13 +717,15 @@ mod test { } #[test] fn idents_name_eq_test() { - assert!(segments_name_eq([Ident{name:3,ctxt:4}, - Ident{name:78,ctxt:82}].map(ident_to_segment), - [Ident{name:3,ctxt:104}, - Ident{name:78,ctxt:182}].map(ident_to_segment))); - assert!(!segments_name_eq([Ident{name:3,ctxt:4}, - Ident{name:78,ctxt:82}].map(ident_to_segment), - [Ident{name:3,ctxt:104}, - Ident{name:77,ctxt:182}].map(ident_to_segment))); + assert!(segments_name_eq( + [Ident{name:3,ctxt:4}, Ident{name:78,ctxt:82}] + .iter().map(ident_to_segment).collect::<Vec<PathSegment>>().as_slice(), + [Ident{name:3,ctxt:104}, Ident{name:78,ctxt:182}] + .iter().map(ident_to_segment).collect::<Vec<PathSegment>>().as_slice())); + assert!(!segments_name_eq( + [Ident{name:3,ctxt:4}, Ident{name:78,ctxt:82}] + .iter().map(ident_to_segment).collect::<Vec<PathSegment>>().as_slice(), + [Ident{name:3,ctxt:104}, Ident{name:77,ctxt:182}] + .iter().map(ident_to_segment).collect::<Vec<PathSegment>>().as_slice())); } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 1c2c63cd919..489af0fc2d4 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -746,7 +746,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn lambda(&self, span: Span, ids: Vec<ast::Ident> , blk: P<ast::Block>) -> @ast::Expr { let fn_decl = self.fn_decl( - ids.map(|id| self.arg(span, *id, self.ty_infer(span))), + ids.iter().map(|id| self.arg(span, *id, self.ty_infer(span))).collect(), self.ty_infer(span)); self.expr(span, ast::ExprFnBlock(fn_decl, blk)) @@ -966,16 +966,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn view_use_list(&self, sp: Span, vis: ast::Visibility, path: Vec<ast::Ident> , imports: &[ast::Ident]) -> ast::ViewItem { - let imports = imports.map(|id| { + let imports = imports.iter().map(|id| { respan(sp, ast::PathListIdent_ { name: *id, id: ast::DUMMY_NODE_ID }) - }); + }).collect(); self.view_use(sp, vis, vec!(@respan(sp, ast::ViewPathList(self.path(sp, path), - imports.iter() - .map(|x| *x) - .collect(), + imports, ast::DUMMY_NODE_ID)))) } diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 3cbccae664b..367accb4b19 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -71,11 +71,11 @@ fn cs_clone( if all_fields.len() >= 1 && all_fields.get(0).name.is_none() { // enum-like - let subcalls = all_fields.map(subcall); + let subcalls = all_fields.iter().map(subcall).collect(); cx.expr_call_ident(trait_span, ctor_ident, subcalls) } else { // struct-like - let fields = all_fields.map(|field| { + let fields = all_fields.iter().map(|field| { let ident = match field.name { Some(i) => i, None => cx.span_bug(trait_span, @@ -83,7 +83,7 @@ fn cs_clone( name)) }; cx.field_imm(field.span, ident, subcall(field)) - }); + }).collect::<Vec<_>>(); if fields.is_empty() { // no fields, so construct like `None` diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index 46e9dfb89ab..94675f91e9d 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -56,14 +56,14 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur if fields.is_empty() { cx.expr_ident(trait_span, substr.type_ident) } else { - let exprs = fields.map(|sp| default_call(*sp)); + let exprs = fields.iter().map(|sp| default_call(*sp)).collect(); cx.expr_call_ident(trait_span, substr.type_ident, exprs) } } Named(ref fields) => { - let default_fields = fields.map(|&(ident, span)| { + let default_fields = fields.iter().map(|&(ident, span)| { cx.field_imm(span, ident, default_call(span)) - }); + }).collect(); cx.expr_struct_ident(trait_span, substr.type_ident, default_fields) } } diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 5454d8912a5..b7b4d3db64a 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -371,12 +371,12 @@ impl<'a> TraitDef<'a> { ty_params.extend(generics.ty_params.iter().map(|ty_param| { // I don't think this can be moved out of the loop, since // a TyParamBound requires an ast id - let mut bounds = + let mut bounds: Vec<_> = // extra restrictions on the generics parameters to the type being derived upon - self.additional_bounds.map(|p| { + self.additional_bounds.iter().map(|p| { cx.typarambound(p.to_path(cx, self.span, type_ident, generics)) - }); + }).collect(); // require the current trait bounds.push(cx.typarambound(trait_path.clone())); @@ -413,7 +413,7 @@ impl<'a> TraitDef<'a> { ident, vec::append(vec!(attr), self.attributes.as_slice()), ast::ItemImpl(trait_generics, opt_trait_ref, - self_type, methods.map(|x| *x))) + self_type, methods)) } fn expand_struct_def(&self, @@ -421,7 +421,7 @@ impl<'a> TraitDef<'a> { struct_def: &StructDef, type_ident: Ident, generics: &Generics) -> @ast::Item { - let methods = self.methods.map(|method_def| { + let methods = self.methods.iter().map(|method_def| { let (explicit_self, self_args, nonself_args, tys) = method_def.split_self_nonself_args( cx, self, type_ident, generics); @@ -447,7 +447,7 @@ impl<'a> TraitDef<'a> { type_ident, generics, explicit_self, tys, body) - }); + }).collect(); self.create_derived_impl(cx, type_ident, generics, methods) } @@ -457,7 +457,7 @@ impl<'a> TraitDef<'a> { enum_def: &EnumDef, type_ident: Ident, generics: &Generics) -> @ast::Item { - let methods = self.methods.map(|method_def| { + let methods = self.methods.iter().map(|method_def| { let (explicit_self, self_args, nonself_args, tys) = method_def.split_self_nonself_args(cx, self, type_ident, generics); @@ -483,7 +483,7 @@ impl<'a> TraitDef<'a> { type_ident, generics, explicit_self, tys, body) - }); + }).collect(); self.create_derived_impl(cx, type_ident, generics, methods) } @@ -955,18 +955,18 @@ impl<'a> MethodDef<'a> { self_args: &[@Expr], nonself_args: &[@Expr]) -> @Expr { - let summary = enum_def.variants.map(|v| { + let summary = enum_def.variants.iter().map(|v| { let ident = v.node.name; let summary = match v.node.kind { ast::TupleVariantKind(ref args) => { - Unnamed(args.map(|va| trait_.set_expn_info(cx, va.ty.span))) + Unnamed(args.iter().map(|va| trait_.set_expn_info(cx, va.ty.span)).collect()) } ast::StructVariantKind(struct_def) => { trait_.summarise_struct(cx, struct_def) } }; (ident, v.span, summary) - }); + }).collect(); self.call_substructure_method(cx, trait_, type_ident, self_args, nonself_args, &StaticEnum(enum_def, summary)) @@ -1027,10 +1027,10 @@ impl<'a> TraitDef<'a> { field_paths: Vec<ast::Path> , mutbl: ast::Mutability) -> Vec<@ast::Pat> { - field_paths.map(|path| { + field_paths.iter().map(|path| { cx.pat(path.span, ast::PatIdent(ast::BindByRef(mutbl), (*path).clone(), None)) - }) + }).collect() } fn create_struct_pattern(&self, @@ -1200,12 +1200,14 @@ pub fn cs_same_method(f: |&mut ExtCtxt, Span, Vec<@Expr> | -> @Expr, match *substructure.fields { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { // call self_n.method(other_1_n, other_2_n, ...) - let called = all_fields.map(|field| { + let called = all_fields.iter().map(|field| { cx.expr_method_call(field.span, field.self_, substructure.method_ident, - field.other.map(|e| cx.expr_addr_of(field.span, *e))) - }); + field.other.iter() + .map(|e| cx.expr_addr_of(field.span, *e)) + .collect()) + }).collect(); f(cx, trait_span, called) }, diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index a31759065ae..6b824e52bb3 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -136,15 +136,15 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) if fields.is_empty() { cx.expr_ident(trait_span, ctor_ident) } else { - let exprs = fields.map(|span| rand_call(cx, *span)); + let exprs = fields.iter().map(|span| rand_call(cx, *span)).collect(); cx.expr_call_ident(trait_span, ctor_ident, exprs) } } Named(ref fields) => { - let rand_fields = fields.map(|&(ident, span)| { + let rand_fields = fields.iter().map(|&(ident, span)| { let e = rand_call(cx, span); cx.field_imm(span, ident, e) - }); + }).collect(); cx.expr_struct_ident(trait_span, ctor_ident, rand_fields) } } diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index bfdfba7ba78..e58c024fcb0 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -69,9 +69,9 @@ impl<'a> Path<'a> { self_ty: Ident, self_generics: &Generics) -> ast::Path { - let idents = self.path.map(|s| cx.ident_of(*s) ); + let idents = self.path.iter().map(|s| cx.ident_of(*s)).collect(); let lt = mk_lifetimes(cx, span, &self.lifetime); - let tys = self.params.map(|t| t.to_ty(cx, span, self_ty, self_generics)); + let tys = self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics)).collect(); cx.path_all(span, self.global, idents, lt, tys) } @@ -150,7 +150,9 @@ impl<'a> Ty<'a> { let ty = if fields.is_empty() { ast::TyNil } else { - ast::TyTup(fields.map(|f| f.to_ty(cx, span, self_ty, self_generics))) + ast::TyTup(fields.iter() + .map(|f| f.to_ty(cx, span, self_ty, self_generics)) + .collect()) }; cx.ty(span, ty) @@ -219,10 +221,10 @@ impl<'a> LifetimeBounds<'a> { self_ty: Ident, self_generics: &Generics) -> Generics { - let lifetimes = self.lifetimes.map(|lt| { + let lifetimes = self.lifetimes.iter().map(|lt| { cx.lifetime(span, cx.ident_of(*lt).name) - }); - let ty_params = self.bounds.map(|t| { + }).collect(); + let ty_params = self.bounds.iter().map(|t| { match t { &(ref name, ref bounds) => { mk_ty_param(cx, @@ -233,7 +235,7 @@ impl<'a> LifetimeBounds<'a> { self_generics) } } - }); + }).collect(); mk_generics(lifetimes, ty_params) } } diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index 9feae186894..10692bd7f93 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -73,14 +73,14 @@ fn zero_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) if fields.is_empty() { cx.expr_ident(trait_span, substr.type_ident) } else { - let exprs = fields.map(|sp| zero_call(*sp)); + let exprs = fields.iter().map(|sp| zero_call(*sp)).collect(); cx.expr_call_ident(trait_span, substr.type_ident, exprs) } } Named(ref fields) => { - let zero_fields = fields.map(|&(ident, span)| { + let zero_fields = fields.iter().map(|&(ident, span)| { cx.field_imm(span, ident, zero_call(span)) - }); + }).collect(); cx.expr_struct_ident(trait_span, substr.type_ident, zero_fields) } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e6494bf1aca..aa9330bf657 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -776,7 +776,7 @@ pub fn expand_block(blk: &Block, fld: &mut MacroExpander) -> P<Block> { // expand the elements of a block. pub fn expand_block_elts(b: &Block, fld: &mut MacroExpander) -> P<Block> { - let new_view_items = b.view_items.map(|x| fld.fold_view_item(x)); + let new_view_items = b.view_items.iter().map(|x| fld.fold_view_item(x)).collect(); let new_stmts = b.stmts.iter().flat_map(|x| { let renamed_stmt = { diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 14847aee8cf..6f8656f494d 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -83,7 +83,7 @@ pub mod rt { impl<'a> ToSource for &'a [@ast::Item] { fn to_source(&self) -> ~str { - self.map(|i| i.to_source()).connect("\n\n") + self.iter().map(|i| i.to_source()).collect::<Vec<~str>>().connect("\n\n") } } @@ -95,7 +95,7 @@ pub mod rt { impl<'a> ToSource for &'a [ast::Ty] { fn to_source(&self) -> ~str { - self.map(|i| i.to_source()).connect(", ") + self.iter().map(|i| i.to_source()).collect::<Vec<~str>>().connect(", ") } } @@ -339,7 +339,7 @@ pub fn expand_quote_stmt(cx: &mut ExtCtxt, } fn ids_ext(strs: Vec<~str> ) -> Vec<ast::Ident> { - strs.map(|str| str_to_ident(*str)) + strs.iter().map(|str| str_to_ident(*str)).collect() } fn id_ext(str: &str) -> ast::Ident { diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 8931fb0f443..4d8d816d225 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -71,7 +71,9 @@ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "module_path!"); let string = cx.mod_path() + .iter() .map(|x| token::get_ident(*x).get().to_str()) + .collect::<Vec<~str>>() .connect("::"); base::MRExpr(cx.expr_str(sp, token::intern_and_get_ident(string))) } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index ae537cc4782..62999fb496a 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -373,7 +373,7 @@ pub fn parse(sess: &ParseSess, } else { if (bb_eis.len() > 0u && next_eis.len() > 0u) || bb_eis.len() > 1u { - let nts = bb_eis.map(|ei| { + let nts = bb_eis.iter().map(|ei| { match ei.elts.get(ei.idx).node { MatchNonterminal(bind, name, _) => { format!("{} ('{}')", @@ -381,7 +381,7 @@ pub fn parse(sess: &ParseSess, token::get_ident(bind)) } _ => fail!() - } }).connect(" or "); + } }).collect::<Vec<~str>>().connect(" or "); return Error(sp, format!( "local ambiguity: multiple parsing options: \ built-in NTs {} or {} other options.", diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 0f8c74f9ee0..03963219d52 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -41,7 +41,7 @@ pub trait Folder { } ViewPathList(ref path, ref path_list_idents, node_id) => { ViewPathList(self.fold_path(path), - path_list_idents.map(|path_list_ident| { + path_list_idents.iter().map(|path_list_ident| { let id = self.new_id(path_list_ident.node .id); Spanned { @@ -54,7 +54,7 @@ pub trait Folder { span: self.new_span( path_list_ident.span) } - }), + }).collect(), self.new_id(node_id)) } }; @@ -83,7 +83,7 @@ pub trait Folder { kind: sf.node.kind, id: self.new_id(sf.node.id), ty: self.fold_ty(sf.node.ty), - attrs: sf.node.attrs.map(|e| fold_attribute_(*e, self)) + attrs: sf.node.attrs.iter().map(|e| fold_attribute_(*e, self)).collect() }, span: self.new_span(sf.span) } @@ -115,7 +115,7 @@ pub trait Folder { fn fold_arm(&mut self, a: &Arm) -> Arm { Arm { - pats: a.pats.map(|x| self.fold_pat(*x)), + pats: a.pats.iter().map(|x| self.fold_pat(*x)).collect(), guard: a.guard.map(|x| self.fold_expr(x)), body: self.fold_expr(a.body), } @@ -163,18 +163,18 @@ pub trait Folder { onceness: f.onceness, bounds: fold_opt_bounds(&f.bounds, self), decl: self.fold_fn_decl(f.decl), - lifetimes: f.lifetimes.map(|l| fold_lifetime(l, self)), + lifetimes: f.lifetimes.iter().map(|l| fold_lifetime(l, self)).collect(), }) } TyBareFn(ref f) => { TyBareFn(@BareFnTy { - lifetimes: f.lifetimes.map(|l| fold_lifetime(l, self)), + lifetimes: f.lifetimes.iter().map(|l| fold_lifetime(l, self)).collect(), purity: f.purity, abis: f.abis, decl: self.fold_fn_decl(f.decl) }) } - TyTup(ref tys) => TyTup(tys.map(|&ty| self.fold_ty(ty))), + TyTup(ref tys) => TyTup(tys.iter().map(|&ty| self.fold_ty(ty)).collect()), TyPath(ref path, ref bounds, id) => { TyPath(self.fold_path(path), fold_opt_bounds(bounds, self), @@ -214,8 +214,8 @@ pub trait Folder { let kind; match v.node.kind { TupleVariantKind(ref variant_args) => { - kind = TupleVariantKind(variant_args.map(|x| - fold_variant_arg_(x, self))) + kind = TupleVariantKind(variant_args.iter().map(|x| + fold_variant_arg_(x, self)).collect()) } StructVariantKind(ref struct_def) => { kind = StructVariantKind(@ast::StructDef { @@ -226,7 +226,7 @@ pub trait Folder { } } - let attrs = v.node.attrs.map(|x| fold_attribute_(*x, self)); + let attrs = v.node.attrs.iter().map(|x| fold_attribute_(*x, self)).collect(); let de = match v.node.disr_expr { Some(e) => Some(self.fold_expr(e)), @@ -254,11 +254,11 @@ pub trait Folder { ast::Path { span: self.new_span(p.span), global: p.global, - segments: p.segments.map(|segment| ast::PathSegment { + segments: p.segments.iter().map(|segment| ast::PathSegment { identifier: self.fold_ident(segment.identifier), - lifetimes: segment.lifetimes.map(|l| fold_lifetime(l, self)), - types: segment.types.map(|&typ| self.fold_ty(typ)), - }) + lifetimes: segment.lifetimes.iter().map(|l| fold_lifetime(l, self)).collect(), + types: segment.types.iter().map(|&typ| self.fold_ty(typ)).collect(), + }).collect() } } @@ -323,7 +323,7 @@ fn fold_meta_item_<T: Folder>(mi: @MetaItem, fld: &mut T) -> @MetaItem { match mi.node { MetaWord(ref id) => MetaWord((*id).clone()), MetaList(ref id, ref mis) => { - MetaList((*id).clone(), mis.map(|e| fold_meta_item_(*e, fld))) + MetaList((*id).clone(), mis.iter().map(|e| fold_meta_item_(*e, fld)).collect()) } MetaNameValue(ref id, ref s) => { MetaNameValue((*id).clone(), (*s).clone()) @@ -402,7 +402,7 @@ fn maybe_fold_ident<T: Folder>(t: &token::Token, fld: &mut T) -> token::Token { pub fn noop_fold_fn_decl<T: Folder>(decl: &FnDecl, fld: &mut T) -> P<FnDecl> { P(FnDecl { - inputs: decl.inputs.map(|x| fold_arg_(x, fld)), // bad copy + inputs: decl.inputs.iter().map(|x| fold_arg_(x, fld)).collect(), // bad copy output: fld.fold_ty(decl.output), cf: decl.cf, variadic: decl.variadic @@ -441,7 +441,7 @@ pub fn fold_lifetime<T: Folder>(l: &Lifetime, fld: &mut T) -> Lifetime { pub fn fold_lifetimes<T: Folder>(lts: &Vec<Lifetime>, fld: &mut T) -> Vec<Lifetime> { - lts.map(|l| fold_lifetime(l, fld)) + lts.iter().map(|l| fold_lifetime(l, fld)).collect() } pub fn fold_opt_lifetime<T: Folder>(o_lt: &Option<Lifetime>, fld: &mut T) @@ -456,7 +456,7 @@ pub fn fold_generics<T: Folder>(generics: &Generics, fld: &mut T) -> Generics { fn fold_struct_def<T: Folder>(struct_def: @StructDef, fld: &mut T) -> @StructDef { @ast::StructDef { - fields: struct_def.fields.map(|f| fold_struct_field(f, fld)), + fields: struct_def.fields.iter().map(|f| fold_struct_field(f, fld)).collect(), ctor_id: struct_def.ctor_id.map(|cid| fld.new_id(cid)), } } @@ -474,7 +474,7 @@ fn fold_struct_field<T: Folder>(f: &StructField, fld: &mut T) -> StructField { kind: f.node.kind, id: fld.new_id(f.node.id), ty: fld.fold_ty(f.node.ty), - attrs: f.node.attrs.map(|a| fold_attribute_(*a, fld)), + attrs: f.node.attrs.iter().map(|a| fold_attribute_(*a, fld)).collect(), }, span: fld.new_span(f.span), } @@ -525,14 +525,14 @@ pub fn noop_fold_view_item<T: Folder>(vi: &ViewItem, folder: &mut T) }; ViewItem { node: inner_view_item, - attrs: vi.attrs.map(|a| fold_attribute_(*a, folder)), + attrs: vi.attrs.iter().map(|a| fold_attribute_(*a, folder)).collect(), vis: vi.vis, span: folder.new_span(vi.span), } } pub fn noop_fold_block<T: Folder>(b: P<Block>, folder: &mut T) -> P<Block> { - let view_items = b.view_items.map(|x| folder.fold_view_item(x)); + let view_items = b.view_items.iter().map(|x| folder.fold_view_item(x)).collect(); let stmts = b.stmts.iter().flat_map(|s| folder.fold_stmt(*s).move_iter()).collect(); P(Block { id: folder.new_id(b.id), // Needs to be first, for ast_map. @@ -566,9 +566,9 @@ pub fn noop_fold_item_underscore<T: Folder>(i: &Item_, folder: &mut T) -> Item_ ItemEnum(ref enum_definition, ref generics) => { ItemEnum( ast::EnumDef { - variants: enum_definition.variants.map(|&x| { + variants: enum_definition.variants.iter().map(|&x| { folder.fold_variant(x) - }), + }).collect(), }, fold_generics(generics, folder)) } @@ -580,18 +580,18 @@ pub fn noop_fold_item_underscore<T: Folder>(i: &Item_, folder: &mut T) -> Item_ ItemImpl(fold_generics(generics, folder), ifce.as_ref().map(|p| fold_trait_ref(p, folder)), folder.fold_ty(ty), - methods.map(|x| folder.fold_method(*x)) + methods.iter().map(|x| folder.fold_method(*x)).collect() ) } ItemTrait(ref generics, ref traits, ref methods) => { - let methods = methods.map(|method| { + let methods = methods.iter().map(|method| { match *method { Required(ref m) => Required(folder.fold_type_method(m)), Provided(method) => Provided(folder.fold_method(method)) } - }); + }).collect(); ItemTrait(fold_generics(generics, folder), - traits.map(|p| fold_trait_ref(p, folder)), + traits.iter().map(|p| fold_trait_ref(p, folder)).collect(), methods) } ItemMac(ref m) => ItemMac(folder.fold_mac(m)), @@ -602,7 +602,7 @@ pub fn noop_fold_type_method<T: Folder>(m: &TypeMethod, fld: &mut T) -> TypeMeth TypeMethod { id: fld.new_id(m.id), // Needs to be first, for ast_map. ident: fld.fold_ident(m.ident), - attrs: m.attrs.map(|a| fold_attribute_(*a, fld)), + attrs: m.attrs.iter().map(|a| fold_attribute_(*a, fld)).collect(), purity: m.purity, decl: fld.fold_fn_decl(m.decl), generics: fold_generics(&m.generics, fld), @@ -623,8 +623,8 @@ pub fn noop_fold_mod<T: Folder>(m: &Mod, folder: &mut T) -> Mod { pub fn noop_fold_crate<T: Folder>(c: Crate, folder: &mut T) -> Crate { Crate { module: folder.fold_mod(&c.module), - attrs: c.attrs.map(|x| fold_attribute_(*x, folder)), - config: c.config.map(|x| fold_meta_item_(*x, folder)), + attrs: c.attrs.iter().map(|x| fold_attribute_(*x, folder)).collect(), + config: c.config.iter().map(|x| fold_meta_item_(*x, folder)).collect(), span: folder.new_span(c.span), } } @@ -643,7 +643,7 @@ pub fn noop_fold_item<T: Folder>(i: &Item, folder: &mut T) -> SmallVector<@Item> SmallVector::one(@Item { id: id, ident: folder.fold_ident(ident), - attrs: i.attrs.map(|e| fold_attribute_(*e, folder)), + attrs: i.attrs.iter().map(|e| fold_attribute_(*e, folder)).collect(), node: node, vis: i.vis, span: folder.new_span(i.span) @@ -654,11 +654,11 @@ pub fn noop_fold_foreign_item<T: Folder>(ni: &ForeignItem, folder: &mut T) -> @F @ForeignItem { id: folder.new_id(ni.id), // Needs to be first, for ast_map. ident: folder.fold_ident(ni.ident), - attrs: ni.attrs.map(|x| fold_attribute_(*x, folder)), + attrs: ni.attrs.iter().map(|x| fold_attribute_(*x, folder)).collect(), node: match ni.node { ForeignItemFn(ref fdec, ref generics) => { ForeignItemFn(P(FnDecl { - inputs: fdec.inputs.map(|a| fold_arg_(a, folder)), + inputs: fdec.inputs.iter().map(|a| fold_arg_(a, folder)).collect(), output: folder.fold_ty(fdec.output), cf: fdec.cf, variadic: fdec.variadic @@ -677,7 +677,7 @@ pub fn noop_fold_method<T: Folder>(m: &Method, folder: &mut T) -> @Method { @Method { id: folder.new_id(m.id), // Needs to be first, for ast_map. ident: folder.fold_ident(m.ident), - attrs: m.attrs.map(|a| fold_attribute_(*a, folder)), + attrs: m.attrs.iter().map(|a| fold_attribute_(*a, folder)).collect(), generics: fold_generics(&m.generics, folder), explicit_self: folder.fold_explicit_self(&m.explicit_self), purity: m.purity, @@ -700,28 +700,28 @@ pub fn noop_fold_pat<T: Folder>(p: @Pat, folder: &mut T) -> @Pat { PatLit(e) => PatLit(folder.fold_expr(e)), PatEnum(ref pth, ref pats) => { PatEnum(folder.fold_path(pth), - pats.as_ref().map(|pats| pats.map(|x| folder.fold_pat(*x)))) + pats.as_ref().map(|pats| pats.iter().map(|x| folder.fold_pat(*x)).collect())) } PatStruct(ref pth, ref fields, etc) => { let pth_ = folder.fold_path(pth); - let fs = fields.map(|f| { + let fs = fields.iter().map(|f| { ast::FieldPat { ident: f.ident, pat: folder.fold_pat(f.pat) } - }); + }).collect(); PatStruct(pth_, fs, etc) } - PatTup(ref elts) => PatTup(elts.map(|x| folder.fold_pat(*x))), + PatTup(ref elts) => PatTup(elts.iter().map(|x| folder.fold_pat(*x)).collect()), PatUniq(inner) => PatUniq(folder.fold_pat(inner)), PatRegion(inner) => PatRegion(folder.fold_pat(inner)), PatRange(e1, e2) => { PatRange(folder.fold_expr(e1), folder.fold_expr(e2)) }, PatVec(ref before, ref slice, ref after) => { - PatVec(before.map(|x| folder.fold_pat(*x)), + PatVec(before.iter().map(|x| folder.fold_pat(*x)).collect(), slice.map(|x| folder.fold_pat(x)), - after.map(|x| folder.fold_pat(*x))) + after.iter().map(|x| folder.fold_pat(*x)).collect()) } }; @@ -741,21 +741,21 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { ExprBox(folder.fold_expr(p), folder.fold_expr(e)) } ExprVec(ref exprs, mutt) => { - ExprVec(exprs.map(|&x| folder.fold_expr(x)), mutt) + ExprVec(exprs.iter().map(|&x| folder.fold_expr(x)).collect(), mutt) } ExprRepeat(expr, count, mutt) => { ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count), mutt) } - ExprTup(ref elts) => ExprTup(elts.map(|x| folder.fold_expr(*x))), + ExprTup(ref elts) => ExprTup(elts.iter().map(|x| folder.fold_expr(*x)).collect()), ExprCall(f, ref args) => { ExprCall(folder.fold_expr(f), - args.map(|&x| folder.fold_expr(x))) + args.iter().map(|&x| folder.fold_expr(x)).collect()) } ExprMethodCall(i, ref tps, ref args) => { ExprMethodCall( folder.fold_ident(i), - tps.map(|&x| folder.fold_ty(x)), - args.map(|&x| folder.fold_expr(x))) + tps.iter().map(|&x| folder.fold_ty(x)).collect(), + args.iter().map(|&x| folder.fold_expr(x)).collect()) } ExprBinary(binop, lhs, rhs) => { ExprBinary(binop, @@ -790,7 +790,7 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { } ExprMatch(expr, ref arms) => { ExprMatch(folder.fold_expr(expr), - arms.map(|x| folder.fold_arm(x))) + arms.iter().map(|x| folder.fold_arm(x)).collect()) } ExprFnBlock(decl, body) => { ExprFnBlock(folder.fold_fn_decl(decl), folder.fold_block(body)) @@ -810,7 +810,7 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { ExprField(el, id, ref tys) => { ExprField(folder.fold_expr(el), folder.fold_ident(id), - tys.map(|&x| folder.fold_ty(x))) + tys.iter().map(|&x| folder.fold_ty(x)).collect()) } ExprIndex(el, er) => { ExprIndex(folder.fold_expr(el), folder.fold_expr(er)) @@ -823,19 +823,19 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { } ExprInlineAsm(ref a) => { ExprInlineAsm(InlineAsm { - inputs: a.inputs.map(|&(ref c, input)| { + inputs: a.inputs.iter().map(|&(ref c, input)| { ((*c).clone(), folder.fold_expr(input)) - }), - outputs: a.outputs.map(|&(ref c, out)| { + }).collect(), + outputs: a.outputs.iter().map(|&(ref c, out)| { ((*c).clone(), folder.fold_expr(out)) - }), + }).collect(), .. (*a).clone() }) } ExprMac(ref mac) => ExprMac(folder.fold_mac(mac)), ExprStruct(ref path, ref fields, maybe_expr) => { ExprStruct(folder.fold_path(path), - fields.map(|x| fold_field_(*x, folder)), + fields.iter().map(|x| fold_field_(*x, folder)).collect(), maybe_expr.map(|x| folder.fold_expr(x))) }, ExprParen(ex) => ExprParen(folder.fold_expr(ex)) diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 53586a66513..7d337e9c078 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -104,7 +104,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str { } if can_trim { - lines.map(|line| line.slice(i + 1, line.len()).to_owned()) + lines.iter().map(|line| line.slice(i + 1, line.len()).to_owned()).collect() } else { lines } diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index b62990036e5..eb7b3162b52 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -70,7 +70,7 @@ pub fn string_to_pat(source_str: ~str) -> @ast::Pat { // convert a vector of strings to a vector of ast::Ident's pub fn strs_to_idents(ids: Vec<&str> ) -> Vec<ast::Ident> { - ids.map(|u| token::str_to_ident(*u)) + ids.iter().map(|u| token::str_to_ident(*u)).collect() } // does the given string match the pattern? whitespace in the first string |
