Skip to content

Commit 7ba5bef

Browse files
committed
syntax/fold -- remove conflicting (and rather pointless) closures
1 parent ca65c00 commit 7ba5bef

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

src/libsyntax/fold.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ pub trait Folder {
7575
}
7676

7777
fn fold_struct_field(&mut self, sf: &StructField) -> StructField {
78-
let fold_attribute = |x| fold_attribute_(x, self);
79-
8078
Spanned {
8179
node: ast::StructField_ {
8280
kind: sf.node.kind,
8381
id: self.new_id(sf.node.id),
8482
ty: self.fold_ty(sf.node.ty),
85-
attrs: sf.node.attrs.map(|e| fold_attribute(*e))
83+
attrs: sf.node.attrs.map(|e| fold_attribute_(*e, self))
8684
},
8785
span: self.new_span(sf.span)
8886
}
@@ -225,8 +223,7 @@ pub trait Folder {
225223
}
226224
}
227225

228-
let fold_attribute = |x| fold_attribute_(x, self);
229-
let attrs = v.node.attrs.map(|x| fold_attribute(*x));
226+
let attrs = v.node.attrs.map(|x| fold_attribute_(*x, self));
230227

231228
let de = match v.node.disr_expr {
232229
Some(e) => Some(self.fold_expr(e)),
@@ -323,8 +320,7 @@ fn fold_meta_item_<T: Folder>(mi: @MetaItem, fld: &mut T) -> @MetaItem {
323320
match mi.node {
324321
MetaWord(ref id) => MetaWord((*id).clone()),
325322
MetaList(ref id, ref mis) => {
326-
let fold_meta_item = |x| fold_meta_item_(x, fld);
327-
MetaList((*id).clone(), mis.map(|e| fold_meta_item(*e)))
323+
MetaList((*id).clone(), mis.map(|e| fold_meta_item_(*e, fld)))
328324
}
329325
MetaNameValue(ref id, ref s) => {
330326
MetaNameValue((*id).clone(), (*s).clone())
@@ -604,23 +600,18 @@ pub fn noop_fold_mod<T: Folder>(m: &Mod, folder: &mut T) -> Mod {
604600
}
605601

606602
pub fn noop_fold_crate<T: Folder>(c: Crate, folder: &mut T) -> Crate {
607-
let fold_meta_item = |x| fold_meta_item_(x, folder);
608-
let fold_attribute = |x| fold_attribute_(x, folder);
609-
610603
Crate {
611604
module: folder.fold_mod(&c.module),
612-
attrs: c.attrs.map(|x| fold_attribute(*x)),
613-
config: c.config.map(|x| fold_meta_item(*x)),
605+
attrs: c.attrs.map(|x| fold_attribute_(*x, folder)),
606+
config: c.config.map(|x| fold_meta_item_(*x, folder)),
614607
span: folder.new_span(c.span),
615608
}
616609
}
617610

618611
pub fn noop_fold_item<T: Folder>(i: &Item, folder: &mut T) -> SmallVector<@Item> {
619-
let fold_attribute = |x| fold_attribute_(x, folder);
620-
621612
SmallVector::one(@Item {
622613
ident: folder.fold_ident(i.ident),
623-
attrs: i.attrs.map(|e| fold_attribute(*e)),
614+
attrs: i.attrs.map(|e| fold_attribute_(*e, folder)),
624615
id: folder.new_id(i.id),
625616
node: folder.fold_item_underscore(&i.node),
626617
vis: i.vis,
@@ -711,8 +702,6 @@ pub fn noop_fold_pat<T: Folder>(p: @Pat, folder: &mut T) -> @Pat {
711702
}
712703

713704
pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr {
714-
let fold_field = |x| fold_field_(x, folder);
715-
716705
let node = match e.node {
717706
ExprVstore(e, v) => {
718707
ExprVstore(folder.fold_expr(e), v)
@@ -824,7 +813,7 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr {
824813
ExprMac(ref mac) => ExprMac(folder.fold_mac(mac)),
825814
ExprStruct(ref path, ref fields, maybe_expr) => {
826815
ExprStruct(folder.fold_path(path),
827-
fields.map(|x| fold_field(*x)),
816+
fields.map(|x| fold_field_(*x, folder)),
828817
maybe_expr.map(|x| folder.fold_expr(x)))
829818
},
830819
ExprParen(ex) => ExprParen(folder.fold_expr(ex))

0 commit comments

Comments
 (0)