diff options
Diffstat (limited to 'src/libsyntax/ext')
| -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 |
11 files changed, 51 insertions, 47 deletions
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.", |
