diff options
| author | bors <bors@rust-lang.org> | 2014-02-11 15:06:49 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-02-11 15:06:49 -0800 |
| commit | 0ac6e5afda2a9741d50d6b5c557ee16fee44878f (patch) | |
| tree | f3911877e062ef2c5a2188a91b38a128dbd35c2b /src/libsyntax | |
| parent | 2ab248af38c982f42a0a1acf0769e71fa7e77db7 (diff) | |
| parent | 484f0f11e6e49c530cd0351e76989ec6706fa2ce (diff) | |
| download | rust-0ac6e5afda2a9741d50d6b5c557ee16fee44878f.tar.gz rust-0ac6e5afda2a9741d50d6b5c557ee16fee44878f.zip | |
auto merge of #12158 : nikomatsakis/rust/issue-6801-borrowck-closures, r=pcwalton
I factored the commits by affected files, for the most part. The last 7 or 8 contain the meat of the PR. The rest are small changes to closures found in the codebase. Maybe interesting to read to see some of the impact of the rules. r? @pcwalton Fixes #6801
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/rand.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/to_str.rs | 41 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/ext/format.rs | 242 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 25 |
6 files changed, 172 insertions, 168 deletions
diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 47be3067284..9d290c93c64 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -580,10 +580,12 @@ impl<'a> MethodDef<'a> { ast::SelfStatic => None, _ => Some(ast::Arg::new_self(trait_.span, ast::MutImmutable)) }; - let args = arg_types.move_iter().map(|(name, ty)| { - cx.arg(trait_.span, name, ty) - }); - let args = self_arg.move_iter().chain(args).collect(); + let args = { + let args = arg_types.move_iter().map(|(name, ty)| { + cx.arg(trait_.span, name, ty) + }); + self_arg.move_iter().chain(args).collect() + }; let ret_type = self.get_ret_ty(cx, trait_, generics, type_ident); diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index a40317286c9..ef7bd7c2bcd 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -60,7 +60,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) cx.ident_of("Rand"), cx.ident_of("rand") ]; - let rand_call = |span| { + let rand_call = |cx: &mut ExtCtxt, span| { cx.expr_call_global(span, rand_ident.clone(), ~[ rng[0] ]) @@ -111,7 +111,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) let i_expr = cx.expr_uint(v_span, i); let pat = cx.pat_lit(v_span, i_expr); - let thing = rand_thing(cx, v_span, ident, summary, |sp| rand_call(sp)); + let thing = rand_thing(cx, v_span, ident, summary, |cx, sp| rand_call(cx, sp)); cx.arm(v_span, ~[ pat ], thing) }).collect::<~[ast::Arm]>(); @@ -130,20 +130,21 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) trait_span: Span, ctor_ident: Ident, summary: &StaticFields, - rand_call: |Span| -> @Expr) + rand_call: |&mut ExtCtxt, Span| -> @Expr) -> @Expr { match *summary { Unnamed(ref fields) => { if fields.is_empty() { cx.expr_ident(trait_span, ctor_ident) } else { - let exprs = fields.map(|span| rand_call(*span)); + let exprs = fields.map(|span| rand_call(cx, *span)); cx.expr_call_ident(trait_span, ctor_ident, exprs) } } Named(ref fields) => { let rand_fields = fields.map(|&(ident, span)| { - cx.field_imm(span, ident, rand_call(span)) + let e = rand_call(cx, span); + cx.field_imm(span, ident, e) }); cx.expr_struct_ident(trait_span, ctor_ident, rand_fields) } diff --git a/src/libsyntax/ext/deriving/to_str.rs b/src/libsyntax/ext/deriving/to_str.rs index 186f1254493..e5145fb15f7 100644 --- a/src/libsyntax/ext/deriving/to_str.rs +++ b/src/libsyntax/ext/deriving/to_str.rs @@ -67,31 +67,32 @@ fn to_str_substructure(cx: &mut ExtCtxt, span: Span, substr: &Substructure) let mut stmts = ~[cx.stmt_let(span, true, buf, init)]; let push_str = cx.ident_of("push_str"); - let push = |s: @Expr| { - let ebuf = cx.expr_ident(span, buf); - let call = cx.expr_method_call(span, ebuf, push_str, ~[s]); - stmts.push(cx.stmt_expr(call)); - }; + { + let push = |s: @Expr| { + let ebuf = cx.expr_ident(span, buf); + let call = cx.expr_method_call(span, ebuf, push_str, ~[s]); + stmts.push(cx.stmt_expr(call)); + }; - for (i, &FieldInfo {name, span, self_, .. }) in fields.iter().enumerate() { - if i > 0 { - push(cx.expr_str(span, InternedString::new(", "))); - } - match name { - None => {} - Some(id) => { - let interned_id = token::get_ident(id.name); - let name = interned_id.get() + ": "; - push(cx.expr_str(span, - token::intern_and_get_ident(name))); + for (i, &FieldInfo {name, span, self_, .. }) in fields.iter().enumerate() { + if i > 0 { + push(cx.expr_str(span, InternedString::new(", "))); + } + match name { + None => {} + Some(id) => { + let interned_id = token::get_ident(id.name); + let name = interned_id.get() + ": "; + push(cx.expr_str(span, + token::intern_and_get_ident(name))); + } } + push(cx.expr_method_call(span, self_, to_str, ~[])); } - push(cx.expr_method_call(span, self_, to_str, ~[])); + push(cx.expr_str(span, end)); } - push(cx.expr_str(span, end)); - cx.expr_block(cx.block(span, stmts, Some(cx.expr_ident(span, - buf)))) + cx.expr_block(cx.block(span, stmts, Some(cx.expr_ident(span, buf)))) } }; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 69611829c7c..d146cd4dae3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -709,14 +709,15 @@ 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_stmts = b.stmts.iter() - .map(|x| { + let new_stmts = + b.stmts.iter().flat_map(|x| { + let renamed_stmt = { let pending_renames = &mut fld.extsbox.info().pending_renames; let mut rename_fld = renames_to_fold(pending_renames); rename_fld.fold_stmt(*x).expect_one("rename_fold didn't return one value") - }) - .flat_map(|x| fld.fold_stmt(x).move_iter()) - .collect(); + }; + fld.fold_stmt(renamed_stmt).move_iter() + }).collect(); let new_expr = b.expr.map(|x| { let expr = { let pending_renames = &mut fld.extsbox.info().pending_renames; diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 4bc3b804c7f..3eacce5eb1d 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -367,157 +367,167 @@ impl<'a> Context<'a> { return ~[unnamed, allow_dead_code]; } - /// Translate a `parse::Piece` to a static `rt::Piece` - fn trans_piece(&mut self, piece: &parse::Piece) -> @ast::Expr { - let sp = self.fmtsp; - let parsepath = |s: &str| { - ~[self.ecx.ident_of("std"), self.ecx.ident_of("fmt"), - self.ecx.ident_of("parse"), self.ecx.ident_of(s)] - }; - let rtpath = |s: &str| { - ~[self.ecx.ident_of("std"), self.ecx.ident_of("fmt"), - self.ecx.ident_of("rt"), self.ecx.ident_of(s)] - }; - let ctpath = |s: &str| { - ~[self.ecx.ident_of("std"), self.ecx.ident_of("fmt"), - self.ecx.ident_of("parse"), self.ecx.ident_of(s)] - }; - let none = self.ecx.path_global(sp, ~[ + fn parsepath(&self, s: &str) -> ~[ast::Ident] { + ~[self.ecx.ident_of("std"), self.ecx.ident_of("fmt"), + self.ecx.ident_of("parse"), self.ecx.ident_of(s)] + } + + fn rtpath(&self, s: &str) -> ~[ast::Ident] { + ~[self.ecx.ident_of("std"), self.ecx.ident_of("fmt"), + self.ecx.ident_of("rt"), self.ecx.ident_of(s)] + } + + fn ctpath(&self, s: &str) -> ~[ast::Ident] { + ~[self.ecx.ident_of("std"), self.ecx.ident_of("fmt"), + self.ecx.ident_of("parse"), self.ecx.ident_of(s)] + } + + fn none(&self) -> @ast::Expr { + let none = self.ecx.path_global(self.fmtsp, ~[ self.ecx.ident_of("std"), self.ecx.ident_of("option"), self.ecx.ident_of("None")]); - let none = self.ecx.expr_path(none); - let some = |e: @ast::Expr| { - let p = self.ecx.path_global(sp, ~[ + self.ecx.expr_path(none) + } + + fn some(&self, e: @ast::Expr) -> @ast::Expr { + let p = self.ecx.path_global(self.fmtsp, ~[ self.ecx.ident_of("std"), self.ecx.ident_of("option"), self.ecx.ident_of("Some")]); - let p = self.ecx.expr_path(p); - self.ecx.expr_call(sp, p, ~[e]) - }; - let trans_count = |c: parse::Count| { - match c { - parse::CountIs(i) => { - self.ecx.expr_call_global(sp, rtpath("CountIs"), - ~[self.ecx.expr_uint(sp, i)]) - } - parse::CountIsParam(i) => { - self.ecx.expr_call_global(sp, rtpath("CountIsParam"), - ~[self.ecx.expr_uint(sp, i)]) - } - parse::CountImplied => { - let path = self.ecx.path_global(sp, rtpath("CountImplied")); - self.ecx.expr_path(path) - } - parse::CountIsNextParam => { - let path = self.ecx.path_global(sp, rtpath("CountIsNextParam")); - self.ecx.expr_path(path) - } - parse::CountIsName(n) => { - let i = match self.name_positions.find_equiv(&n) { - Some(&i) => i, - None => 0, // error already emitted elsewhere - }; - let i = i + self.args.len(); - self.ecx.expr_call_global(sp, rtpath("CountIsParam"), - ~[self.ecx.expr_uint(sp, i)]) - } + let p = self.ecx.expr_path(p); + self.ecx.expr_call(self.fmtsp, p, ~[e]) + } + + fn trans_count(&self, c: parse::Count) -> @ast::Expr { + let sp = self.fmtsp; + match c { + parse::CountIs(i) => { + self.ecx.expr_call_global(sp, self.rtpath("CountIs"), + ~[self.ecx.expr_uint(sp, i)]) } - }; - let trans_method = |method: &parse::Method| { - let method = match *method { - parse::Select(ref arms, ref default) => { - let arms = arms.iter().map(|arm| { - let p = self.ecx.path_global(sp, rtpath("SelectArm")); + parse::CountIsParam(i) => { + self.ecx.expr_call_global(sp, self.rtpath("CountIsParam"), + ~[self.ecx.expr_uint(sp, i)]) + } + parse::CountImplied => { + let path = self.ecx.path_global(sp, self.rtpath("CountImplied")); + self.ecx.expr_path(path) + } + parse::CountIsNextParam => { + let path = self.ecx.path_global(sp, self.rtpath("CountIsNextParam")); + self.ecx.expr_path(path) + } + parse::CountIsName(n) => { + let i = match self.name_positions.find_equiv(&n) { + Some(&i) => i, + None => 0, // error already emitted elsewhere + }; + let i = i + self.args.len(); + self.ecx.expr_call_global(sp, self.rtpath("CountIsParam"), + ~[self.ecx.expr_uint(sp, i)]) + } + } + } + + fn trans_method(&mut self, method: &parse::Method) -> @ast::Expr { + let sp = self.fmtsp; + let method = match *method { + parse::Select(ref arms, ref default) => { + let arms = arms.iter().map(|arm| { + let p = self.ecx.path_global(sp, self.rtpath("SelectArm")); let result = arm.result.iter().map(|p| { self.trans_piece(p) }).collect(); let s = token::intern_and_get_ident(arm.selector); let selector = self.ecx.expr_str(sp, s); self.ecx.expr_struct(sp, p, ~[ - self.ecx.field_imm(sp, - self.ecx.ident_of("selector"), - selector), - self.ecx.field_imm(sp, self.ecx.ident_of("result"), - self.ecx.expr_vec_slice(sp, result)), - ]) + self.ecx.field_imm(sp, + self.ecx.ident_of("selector"), + selector), + self.ecx.field_imm(sp, self.ecx.ident_of("result"), + self.ecx.expr_vec_slice(sp, result)), + ]) }).collect(); - let default = default.iter().map(|p| { + let default = default.iter().map(|p| { self.trans_piece(p) }).collect(); - self.ecx.expr_call_global(sp, rtpath("Select"), ~[ + self.ecx.expr_call_global(sp, self.rtpath("Select"), ~[ self.ecx.expr_vec_slice(sp, arms), self.ecx.expr_vec_slice(sp, default), - ]) - } - parse::Plural(offset, ref arms, ref default) => { - let offset = match offset { - Some(i) => { some(self.ecx.expr_uint(sp, i)) } - None => { none.clone() } - }; - let arms = arms.iter().map(|arm| { - let p = self.ecx.path_global(sp, rtpath("PluralArm")); + ]) + } + parse::Plural(offset, ref arms, ref default) => { + let offset = match offset { + Some(i) => { self.some(self.ecx.expr_uint(sp, i)) } + None => { self.none() } + }; + let arms = arms.iter().map(|arm| { + let p = self.ecx.path_global(sp, self.rtpath("PluralArm")); let result = arm.result.iter().map(|p| { - self.trans_piece(p) - }).collect(); + self.trans_piece(p) + }).collect(); let (lr, selarg) = match arm.selector { parse::Keyword(t) => { - let p = ctpath(format!("{:?}", t)); + let p = self.ctpath(format!("{:?}", t)); let p = self.ecx.path_global(sp, p); - (rtpath("Keyword"), self.ecx.expr_path(p)) + (self.rtpath("Keyword"), self.ecx.expr_path(p)) } parse::Literal(i) => { - (rtpath("Literal"), self.ecx.expr_uint(sp, i)) + (self.rtpath("Literal"), self.ecx.expr_uint(sp, i)) } }; let selector = self.ecx.expr_call_global(sp, - lr, ~[selarg]); + lr, ~[selarg]); self.ecx.expr_struct(sp, p, ~[ - self.ecx.field_imm(sp, - self.ecx.ident_of("selector"), - selector), - self.ecx.field_imm(sp, self.ecx.ident_of("result"), - self.ecx.expr_vec_slice(sp, result)), - ]) + self.ecx.field_imm(sp, + self.ecx.ident_of("selector"), + selector), + self.ecx.field_imm(sp, self.ecx.ident_of("result"), + self.ecx.expr_vec_slice(sp, result)), + ]) }).collect(); - let default = default.iter().map(|p| { + let default = default.iter().map(|p| { self.trans_piece(p) }).collect(); - self.ecx.expr_call_global(sp, rtpath("Plural"), ~[ + self.ecx.expr_call_global(sp, self.rtpath("Plural"), ~[ offset, self.ecx.expr_vec_slice(sp, arms), self.ecx.expr_vec_slice(sp, default), - ]) - } - }; - let life = self.ecx.lifetime(sp, self.ecx.ident_of("static")); - let ty = self.ecx.ty_path(self.ecx.path_all( + ]) + } + }; + let life = self.ecx.lifetime(sp, self.ecx.ident_of("static")); + let ty = self.ecx.ty_path(self.ecx.path_all( sp, true, - rtpath("Method"), + self.rtpath("Method"), opt_vec::with(life), ~[] - ), None); - let st = ast::ItemStatic(ty, ast::MutImmutable, method); - let static_name = self.ecx.ident_of(format!("__STATIC_METHOD_{}", - self.method_statics.len())); - let item = self.ecx.item(sp, static_name, self.static_attrs(), st); - self.method_statics.push(item); - self.ecx.expr_ident(sp, static_name) - }; + ), None); + let st = ast::ItemStatic(ty, ast::MutImmutable, method); + let static_name = self.ecx.ident_of(format!("__STATIC_METHOD_{}", + self.method_statics.len())); + let item = self.ecx.item(sp, static_name, self.static_attrs(), st); + self.method_statics.push(item); + self.ecx.expr_ident(sp, static_name) + } + /// Translate a `parse::Piece` to a static `rt::Piece` + fn trans_piece(&mut self, piece: &parse::Piece) -> @ast::Expr { + let sp = self.fmtsp; match *piece { parse::String(s) => { let s = token::intern_and_get_ident(s); self.ecx.expr_call_global(sp, - rtpath("String"), + self.rtpath("String"), ~[ self.ecx.expr_str(sp, s) ]) } parse::CurrentArgument => { let nil = self.ecx.expr_lit(sp, ast::LitNil); - self.ecx.expr_call_global(sp, rtpath("CurrentArgument"), ~[nil]) + self.ecx.expr_call_global(sp, self.rtpath("CurrentArgument"), ~[nil]) } parse::Argument(ref arg) => { // Translate the position @@ -525,11 +535,11 @@ impl<'a> Context<'a> { // These two have a direct mapping parse::ArgumentNext => { let path = self.ecx.path_global(sp, - rtpath("ArgumentNext")); + self.rtpath("ArgumentNext")); self.ecx.expr_path(path) } parse::ArgumentIs(i) => { - self.ecx.expr_call_global(sp, rtpath("ArgumentIs"), + self.ecx.expr_call_global(sp, self.rtpath("ArgumentIs"), ~[self.ecx.expr_uint(sp, i)]) } // Named arguments are converted to positional arguments at @@ -540,7 +550,7 @@ impl<'a> Context<'a> { None => 0, // error already emitted elsewhere }; let i = i + self.args.len(); - self.ecx.expr_call_global(sp, rtpath("ArgumentIs"), + self.ecx.expr_call_global(sp, self.rtpath("ArgumentIs"), ~[self.ecx.expr_uint(sp, i)]) } }; @@ -550,20 +560,20 @@ impl<'a> Context<'a> { let fill = self.ecx.expr_lit(sp, ast::LitChar(fill as u32)); let align = match arg.format.align { parse::AlignLeft => { - self.ecx.path_global(sp, parsepath("AlignLeft")) + self.ecx.path_global(sp, self.parsepath("AlignLeft")) } parse::AlignRight => { - self.ecx.path_global(sp, parsepath("AlignRight")) + self.ecx.path_global(sp, self.parsepath("AlignRight")) } parse::AlignUnknown => { - self.ecx.path_global(sp, parsepath("AlignUnknown")) + self.ecx.path_global(sp, self.parsepath("AlignUnknown")) } }; let align = self.ecx.expr_path(align); let flags = self.ecx.expr_uint(sp, arg.format.flags); - let prec = trans_count(arg.format.precision); - let width = trans_count(arg.format.width); - let path = self.ecx.path_global(sp, rtpath("FormatSpec")); + let prec = self.trans_count(arg.format.precision); + let width = self.trans_count(arg.format.width); + let path = self.ecx.path_global(sp, self.rtpath("FormatSpec")); let fmt = self.ecx.expr_struct(sp, path, ~[ self.ecx.field_imm(sp, self.ecx.ident_of("fill"), fill), self.ecx.field_imm(sp, self.ecx.ident_of("align"), align), @@ -574,19 +584,19 @@ impl<'a> Context<'a> { // Translate the method (if any) let method = match arg.method { - None => { none.clone() } + None => { self.none() } Some(ref m) => { - let m = trans_method(*m); - some(self.ecx.expr_addr_of(sp, m)) + let m = self.trans_method(*m); + self.some(self.ecx.expr_addr_of(sp, m)) } }; - let path = self.ecx.path_global(sp, rtpath("Argument")); + let path = self.ecx.path_global(sp, self.rtpath("Argument")); let s = self.ecx.expr_struct(sp, path, ~[ self.ecx.field_imm(sp, self.ecx.ident_of("position"), pos), self.ecx.field_imm(sp, self.ecx.ident_of("format"), fmt), self.ecx.field_imm(sp, self.ecx.ident_of("method"), method), ]); - self.ecx.expr_call_global(sp, rtpath("Argument"), ~[s]) + self.ecx.expr_call_global(sp, self.rtpath("Argument"), ~[s]) } } } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 8fbaea7ac1e..52ff3798f1b 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -75,14 +75,12 @@ pub trait Folder { } fn fold_struct_field(&mut self, sf: &StructField) -> StructField { - let fold_attribute = |x| fold_attribute_(x, self); - Spanned { node: ast::StructField_ { 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)) + attrs: sf.node.attrs.map(|e| fold_attribute_(*e, self)) }, span: self.new_span(sf.span) } @@ -225,8 +223,7 @@ pub trait Folder { } } - let fold_attribute = |x| fold_attribute_(x, self); - let attrs = v.node.attrs.map(|x| fold_attribute(*x)); + let attrs = v.node.attrs.map(|x| fold_attribute_(*x, self)); let de = match v.node.disr_expr { Some(e) => Some(self.fold_expr(e)), @@ -323,8 +320,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) => { - let fold_meta_item = |x| fold_meta_item_(x, fld); - MetaList((*id).clone(), mis.map(|e| fold_meta_item(*e))) + MetaList((*id).clone(), mis.map(|e| fold_meta_item_(*e, fld))) } MetaNameValue(ref id, ref s) => { MetaNameValue((*id).clone(), (*s).clone()) @@ -604,23 +600,18 @@ 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 { - let fold_meta_item = |x| fold_meta_item_(x, folder); - let fold_attribute = |x| fold_attribute_(x, folder); - Crate { module: folder.fold_mod(&c.module), - attrs: c.attrs.map(|x| fold_attribute(*x)), - config: c.config.map(|x| fold_meta_item(*x)), + attrs: c.attrs.map(|x| fold_attribute_(*x, folder)), + config: c.config.map(|x| fold_meta_item_(*x, folder)), span: folder.new_span(c.span), } } pub fn noop_fold_item<T: Folder>(i: &Item, folder: &mut T) -> SmallVector<@Item> { - let fold_attribute = |x| fold_attribute_(x, folder); - SmallVector::one(@Item { ident: folder.fold_ident(i.ident), - attrs: i.attrs.map(|e| fold_attribute(*e)), + attrs: i.attrs.map(|e| fold_attribute_(*e, folder)), id: folder.new_id(i.id), node: folder.fold_item_underscore(&i.node), vis: i.vis, @@ -711,8 +702,6 @@ pub fn noop_fold_pat<T: Folder>(p: @Pat, folder: &mut T) -> @Pat { } pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { - let fold_field = |x| fold_field_(x, folder); - let node = match e.node { ExprVstore(e, v) => { ExprVstore(folder.fold_expr(e), v) @@ -824,7 +813,7 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { 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)), + fields.map(|x| fold_field_(*x, folder)), maybe_expr.map(|x| folder.fold_expr(x))) }, ExprParen(ex) => ExprParen(folder.fold_expr(ex)) |
