@@ -125,10 +125,6 @@ pub trait Folder : Sized {
125125 noop_fold_opt_expr ( e, self )
126126 }
127127
128- fn fold_exprs ( & mut self , es : Vec < P < Expr > > ) -> Vec < P < Expr > > {
129- noop_fold_exprs ( es, self )
130- }
131-
132128 fn fold_generic_arg ( & mut self , arg : GenericArg ) -> GenericArg {
133129 match arg {
134130 GenericArg :: Lifetime ( lt) => GenericArg :: Lifetime ( self . fold_lifetime ( lt) ) ,
@@ -257,10 +253,6 @@ pub trait Folder : Sized {
257253 noop_fold_interpolated ( nt, self )
258254 }
259255
260- fn fold_bounds ( & mut self , b : GenericBounds ) -> GenericBounds {
261- noop_fold_bounds ( b, self )
262- }
263-
264256 fn fold_param_bound ( & mut self , tpb : GenericBound ) -> GenericBound {
265257 noop_fold_param_bound ( tpb, self )
266258 }
@@ -296,6 +288,34 @@ pub trait Folder : Sized {
296288 }
297289}
298290
291+ // No `noop_` prefix because there isn't a corresponding method in `Folder`.
292+ fn fold_attrs < T : Folder > ( attrs : Vec < Attribute > , fld : & mut T ) -> Vec < Attribute > {
293+ attrs. move_map ( |x| fld. fold_attribute ( x) )
294+ }
295+
296+ // No `noop_` prefix because there isn't a corresponding method in `Folder`.
297+ fn fold_thin_attrs < T : Folder > ( attrs : ThinVec < Attribute > , fld : & mut T ) -> ThinVec < Attribute > {
298+ fold_attrs ( attrs. into ( ) , fld) . into ( )
299+ }
300+
301+ // No `noop_` prefix because there isn't a corresponding method in `Folder`.
302+ fn fold_exprs < T : Folder > ( es : Vec < P < Expr > > , fld : & mut T ) -> Vec < P < Expr > > {
303+ es. move_flat_map ( |e| fld. fold_opt_expr ( e) )
304+ }
305+
306+ // No `noop_` prefix because there isn't a corresponding method in `Folder`.
307+ fn fold_bounds < T : Folder > ( bounds : GenericBounds , folder : & mut T ) -> GenericBounds {
308+ bounds. move_map ( |bound| folder. fold_param_bound ( bound) )
309+ }
310+
311+ // No `noop_` prefix because there isn't a corresponding method in `Folder`.
312+ fn fold_method_sig < T : Folder > ( sig : MethodSig , folder : & mut T ) -> MethodSig {
313+ MethodSig {
314+ header : folder. fold_fn_header ( sig. header ) ,
315+ decl : folder. fold_fn_decl ( sig. decl )
316+ }
317+ }
318+
299319pub fn noop_fold_use_tree < T : Folder > ( use_tree : UseTree , fld : & mut T ) -> UseTree {
300320 UseTree {
301321 span : fld. new_span ( use_tree. span ) ,
@@ -312,14 +332,6 @@ pub fn noop_fold_use_tree<T: Folder>(use_tree: UseTree, fld: &mut T) -> UseTree
312332 }
313333}
314334
315- pub fn fold_attrs < T : Folder > ( attrs : Vec < Attribute > , fld : & mut T ) -> Vec < Attribute > {
316- attrs. move_map ( |x| fld. fold_attribute ( x) )
317- }
318-
319- pub fn fold_thin_attrs < T : Folder > ( attrs : ThinVec < Attribute > , fld : & mut T ) -> ThinVec < Attribute > {
320- fold_attrs ( attrs. into ( ) , fld) . into ( )
321- }
322-
323335pub fn noop_fold_arm < T : Folder > ( Arm { attrs, pats, guard, body} : Arm ,
324336 fld : & mut T ) -> Arm {
325337 Arm {
@@ -824,11 +836,6 @@ pub fn noop_fold_mt<T: Folder>(MutTy {ty, mutbl}: MutTy, folder: &mut T) -> MutT
824836 }
825837}
826838
827- fn noop_fold_bounds < T : Folder > ( bounds : GenericBounds , folder : & mut T )
828- -> GenericBounds {
829- bounds. move_map ( |bound| folder. fold_param_bound ( bound) )
830- }
831-
832839pub fn noop_fold_block < T : Folder > ( b : P < Block > , folder : & mut T ) -> P < Block > {
833840 b. map ( |Block { id, stmts, rules, span} | Block {
834841 id : folder. new_id ( id) ,
@@ -864,7 +871,7 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
864871 ItemKind :: Ty ( folder. fold_ty ( t) , folder. fold_generics ( generics) )
865872 }
866873 ItemKind :: Existential ( bounds, generics) => ItemKind :: Existential (
867- folder . fold_bounds ( bounds) ,
874+ fold_bounds ( bounds, folder ) ,
868875 folder. fold_generics ( generics) ,
869876 ) ,
870877 ItemKind :: Enum ( enum_definition, generics) => {
@@ -899,12 +906,12 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
899906 is_auto,
900907 unsafety,
901908 folder. fold_generics ( generics) ,
902- folder . fold_bounds ( bounds) ,
909+ fold_bounds ( bounds, folder ) ,
903910 items. move_flat_map ( |item| folder. fold_trait_item ( item) ) ,
904911 ) ,
905912 ItemKind :: TraitAlias ( generics, bounds) => ItemKind :: TraitAlias (
906913 folder. fold_generics ( generics) ,
907- folder . fold_bounds ( bounds) ) ,
914+ fold_bounds ( bounds, folder ) ) ,
908915 ItemKind :: Mac ( m) => ItemKind :: Mac ( folder. fold_mac ( m) ) ,
909916 ItemKind :: MacroDef ( def) => ItemKind :: MacroDef ( folder. fold_macro_def ( def) ) ,
910917 }
@@ -922,11 +929,11 @@ pub fn noop_fold_trait_item<T: Folder>(i: TraitItem, folder: &mut T) -> SmallVec
922929 default . map( |x| folder. fold_expr( x) ) )
923930 }
924931 TraitItemKind :: Method ( sig, body) => {
925- TraitItemKind :: Method ( noop_fold_method_sig ( sig, folder) ,
932+ TraitItemKind :: Method ( fold_method_sig ( sig, folder) ,
926933 body. map( |x| folder. fold_block( x) ) )
927934 }
928935 TraitItemKind :: Type ( bounds, default ) => {
929- TraitItemKind :: Type ( folder . fold_bounds( bounds) ,
936+ TraitItemKind :: Type ( fold_bounds( bounds, folder ) ,
930937 default . map( |x| folder. fold_ty( x) ) )
931938 }
932939 TraitItemKind :: Macro ( mac) => {
@@ -951,12 +958,12 @@ pub fn noop_fold_impl_item<T: Folder>(i: ImplItem, folder: &mut T)-> SmallVec<[I
951958 ImplItemKind :: Const ( folder. fold_ty( ty) , folder. fold_expr( expr) )
952959 }
953960 ImplItemKind :: Method ( sig, body) => {
954- ImplItemKind :: Method ( noop_fold_method_sig ( sig, folder) ,
961+ ImplItemKind :: Method ( fold_method_sig ( sig, folder) ,
955962 folder. fold_block( body) )
956963 }
957964 ImplItemKind :: Type ( ty) => ImplItemKind :: Type ( folder. fold_ty( ty) ) ,
958965 ImplItemKind :: Existential ( bounds) => {
959- ImplItemKind :: Existential ( folder . fold_bounds( bounds) )
966+ ImplItemKind :: Existential ( fold_bounds( bounds, folder ) )
960967 } ,
961968 ImplItemKind :: Macro ( mac) => ImplItemKind :: Macro ( folder. fold_mac( mac) )
962969 } ,
@@ -1047,13 +1054,6 @@ pub fn noop_fold_foreign_item<T: Folder>(ni: ForeignItem, folder: &mut T)
10471054 } ]
10481055}
10491056
1050- pub fn noop_fold_method_sig < T : Folder > ( sig : MethodSig , folder : & mut T ) -> MethodSig {
1051- MethodSig {
1052- header : folder. fold_fn_header ( sig. header ) ,
1053- decl : folder. fold_fn_decl ( sig. decl )
1054- }
1055- }
1056-
10571057pub fn noop_fold_pat < T : Folder > ( p : P < Pat > , folder : & mut T ) -> P < Pat > {
10581058 p. map ( |Pat { id, node, span} | Pat {
10591059 id : folder. new_id ( id) ,
@@ -1125,15 +1125,15 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
11251125 ExprKind :: ObsoleteInPlace ( folder. fold_expr ( a) , folder. fold_expr ( b) )
11261126 }
11271127 ExprKind :: Array ( exprs) => {
1128- ExprKind :: Array ( folder . fold_exprs ( exprs) )
1128+ ExprKind :: Array ( fold_exprs ( exprs, folder ) )
11291129 }
11301130 ExprKind :: Repeat ( expr, count) => {
11311131 ExprKind :: Repeat ( folder. fold_expr ( expr) , folder. fold_anon_const ( count) )
11321132 }
1133- ExprKind :: Tup ( exprs) => ExprKind :: Tup ( folder . fold_exprs ( exprs) ) ,
1133+ ExprKind :: Tup ( exprs) => ExprKind :: Tup ( fold_exprs ( exprs, folder ) ) ,
11341134 ExprKind :: Call ( f, args) => {
11351135 ExprKind :: Call ( folder. fold_expr ( f) ,
1136- folder . fold_exprs ( args) )
1136+ fold_exprs ( args, folder ) )
11371137 }
11381138 ExprKind :: MethodCall ( seg, args) => {
11391139 ExprKind :: MethodCall (
@@ -1144,7 +1144,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
11441144 args. map ( |args| folder. fold_generic_args ( args) )
11451145 } ) ,
11461146 } ,
1147- folder . fold_exprs ( args) )
1147+ fold_exprs ( args, folder ) )
11481148 }
11491149 ExprKind :: Binary ( binop, lhs, rhs) => {
11501150 ExprKind :: Binary ( binop,
@@ -1294,10 +1294,6 @@ pub fn noop_fold_opt_expr<T: Folder>(e: P<Expr>, folder: &mut T) -> Option<P<Exp
12941294 Some ( folder. fold_expr ( e) )
12951295}
12961296
1297- pub fn noop_fold_exprs < T : Folder > ( es : Vec < P < Expr > > , folder : & mut T ) -> Vec < P < Expr > > {
1298- es. move_flat_map ( |e| folder. fold_opt_expr ( e) )
1299- }
1300-
13011297pub fn noop_fold_stmt < T : Folder > ( Stmt { node, span, id} : Stmt , folder : & mut T ) -> SmallVec < [ Stmt ; 1 ] >
13021298{
13031299 let id = folder. new_id ( id) ;
0 commit comments