Skip to content

Commit 501f2d9

Browse files
committed
---
yaml --- r: 152906 b: refs/heads/try2 c: 4b833e2 h: refs/heads/master v: v3
1 parent bb96f3e commit 501f2d9

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b8c5e4650598f43a2e362bcf6f4e919440a997bb
8+
refs/heads/try2: 4b833e24c39112d2e59cfc1287483c2fe61c34e4
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libsyntax/fold.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub trait Folder {
8686
kind: sf.node.kind,
8787
id: id,
8888
ty: self.fold_ty(sf.node.ty),
89-
attrs: sf.node.attrs.iter().map(|e| fold_attribute_(*e, self)).collect()
89+
attrs: sf.node.attrs.iter().map(|e| self.fold_attribute(*e)).collect()
9090
},
9191
span: self.new_span(sf.span)
9292
}
@@ -118,7 +118,7 @@ pub trait Folder {
118118

119119
fn fold_arm(&mut self, a: &Arm) -> Arm {
120120
Arm {
121-
attrs: a.attrs.iter().map(|x| fold_attribute_(*x, self)).collect(),
121+
attrs: a.attrs.iter().map(|x| self.fold_attribute(*x)).collect(),
122122
pats: a.pats.iter().map(|x| self.fold_pat(*x)).collect(),
123123
guard: a.guard.map(|x| self.fold_expr(x)),
124124
body: self.fold_expr(a.body),
@@ -251,7 +251,7 @@ pub trait Folder {
251251
}
252252
}
253253

254-
let attrs = v.node.attrs.iter().map(|x| fold_attribute_(*x, self)).collect();
254+
let attrs = v.node.attrs.iter().map(|x| self.fold_attribute(*x)).collect();
255255

256256
let de = match v.node.disr_expr {
257257
Some(e) => Some(self.fold_expr(e)),
@@ -344,6 +344,21 @@ pub trait Folder {
344344
fn fold_lifetime(&mut self, l: &Lifetime) -> Lifetime {
345345
noop_fold_lifetime(l, self)
346346
}
347+
348+
//used in noop_fold_item and noop_fold_crate
349+
fn fold_attribute(&mut self, at: Attribute) -> Attribute {
350+
Spanned {
351+
span: self.new_span(at.span),
352+
node: ast::Attribute_ {
353+
id: at.node.id,
354+
style: at.node.style,
355+
value: fold_meta_item_(at.node.value, self),
356+
is_sugared_doc: at.node.is_sugared_doc
357+
}
358+
}
359+
}
360+
361+
347362
}
348363

349364
/* some little folds that probably aren't useful to have in Folder itself*/
@@ -364,19 +379,6 @@ fn fold_meta_item_<T: Folder>(mi: Gc<MetaItem>, fld: &mut T) -> Gc<MetaItem> {
364379
span: fld.new_span(mi.span) }
365380
}
366381

367-
//used in noop_fold_item and noop_fold_crate
368-
fn fold_attribute_<T: Folder>(at: Attribute, fld: &mut T) -> Attribute {
369-
Spanned {
370-
span: fld.new_span(at.span),
371-
node: ast::Attribute_ {
372-
id: at.node.id,
373-
style: at.node.style,
374-
value: fold_meta_item_(at.node.value, fld),
375-
is_sugared_doc: at.node.is_sugared_doc
376-
}
377-
}
378-
}
379-
380382
//used in noop_fold_foreign_item and noop_fold_fn_decl
381383
fn fold_arg_<T: Folder>(a: &Arg, fld: &mut T) -> Arg {
382384
let id = fld.new_id(a.id); // Needs to be first, for ast_map.
@@ -526,7 +528,7 @@ fn fold_struct_field<T: Folder>(f: &StructField, fld: &mut T) -> StructField {
526528
kind: f.node.kind,
527529
id: id,
528530
ty: fld.fold_ty(f.node.ty),
529-
attrs: f.node.attrs.iter().map(|a| fold_attribute_(*a, fld)).collect(),
531+
attrs: f.node.attrs.iter().map(|a| fld.fold_attribute(*a)).collect(),
530532
},
531533
span: fld.new_span(f.span),
532534
}
@@ -578,7 +580,7 @@ pub fn noop_fold_view_item<T: Folder>(vi: &ViewItem, folder: &mut T)
578580
};
579581
ViewItem {
580582
node: inner_view_item,
581-
attrs: vi.attrs.iter().map(|a| fold_attribute_(*a, folder)).collect(),
583+
attrs: vi.attrs.iter().map(|a| folder.fold_attribute(*a)).collect(),
582584
vis: vi.vis,
583585
span: folder.new_span(vi.span),
584586
}
@@ -658,7 +660,7 @@ pub fn noop_fold_type_method<T: Folder>(m: &TypeMethod, fld: &mut T) -> TypeMeth
658660
TypeMethod {
659661
id: id,
660662
ident: fld.fold_ident(m.ident),
661-
attrs: m.attrs.iter().map(|a| fold_attribute_(*a, fld)).collect(),
663+
attrs: m.attrs.iter().map(|a| fld.fold_attribute(*a)).collect(),
662664
fn_style: m.fn_style,
663665
decl: fld.fold_fn_decl(&*m.decl),
664666
generics: fold_generics(&m.generics, fld),
@@ -681,7 +683,7 @@ pub fn noop_fold_mod<T: Folder>(m: &Mod, folder: &mut T) -> Mod {
681683
pub fn noop_fold_crate<T: Folder>(c: Crate, folder: &mut T) -> Crate {
682684
Crate {
683685
module: folder.fold_mod(&c.module),
684-
attrs: c.attrs.iter().map(|x| fold_attribute_(*x, folder)).collect(),
686+
attrs: c.attrs.iter().map(|x| folder.fold_attribute(*x)).collect(),
685687
config: c.config.iter().map(|x| fold_meta_item_(*x, folder)).collect(),
686688
span: folder.new_span(c.span),
687689
}
@@ -702,7 +704,7 @@ pub fn noop_fold_item<T: Folder>(i: &Item,
702704
SmallVector::one(box(GC) Item {
703705
id: id,
704706
ident: folder.fold_ident(ident),
705-
attrs: i.attrs.iter().map(|e| fold_attribute_(*e, folder)).collect(),
707+
attrs: i.attrs.iter().map(|e| folder.fold_attribute(*e)).collect(),
706708
node: node,
707709
vis: i.vis,
708710
span: folder.new_span(i.span)
@@ -715,7 +717,7 @@ pub fn noop_fold_foreign_item<T: Folder>(ni: &ForeignItem,
715717
box(GC) ForeignItem {
716718
id: id,
717719
ident: folder.fold_ident(ni.ident),
718-
attrs: ni.attrs.iter().map(|x| fold_attribute_(*x, folder)).collect(),
720+
attrs: ni.attrs.iter().map(|x| folder.fold_attribute(*x)).collect(),
719721
node: match ni.node {
720722
ForeignItemFn(ref fdec, ref generics) => {
721723
ForeignItemFn(P(FnDecl {
@@ -739,7 +741,7 @@ pub fn noop_fold_method<T: Folder>(m: &Method, folder: &mut T) -> Gc<Method> {
739741
box(GC) Method {
740742
id: id,
741743
ident: folder.fold_ident(m.ident),
742-
attrs: m.attrs.iter().map(|a| fold_attribute_(*a, folder)).collect(),
744+
attrs: m.attrs.iter().map(|a| folder.fold_attribute(*a)).collect(),
743745
generics: fold_generics(&m.generics, folder),
744746
explicit_self: folder.fold_explicit_self(&m.explicit_self),
745747
fn_style: m.fn_style,

0 commit comments

Comments
 (0)