@@ -125,10 +125,6 @@ pub trait Folder : Sized {
125
125
noop_fold_opt_expr ( e, self )
126
126
}
127
127
128
- fn fold_exprs ( & mut self , es : Vec < P < Expr > > ) -> Vec < P < Expr > > {
129
- noop_fold_exprs ( es, self )
130
- }
131
-
132
128
fn fold_generic_arg ( & mut self , arg : GenericArg ) -> GenericArg {
133
129
match arg {
134
130
GenericArg :: Lifetime ( lt) => GenericArg :: Lifetime ( self . fold_lifetime ( lt) ) ,
@@ -257,10 +253,6 @@ pub trait Folder : Sized {
257
253
noop_fold_interpolated ( nt, self )
258
254
}
259
255
260
- fn fold_bounds ( & mut self , b : GenericBounds ) -> GenericBounds {
261
- noop_fold_bounds ( b, self )
262
- }
263
-
264
256
fn fold_param_bound ( & mut self , tpb : GenericBound ) -> GenericBound {
265
257
noop_fold_param_bound ( tpb, self )
266
258
}
@@ -296,6 +288,34 @@ pub trait Folder : Sized {
296
288
}
297
289
}
298
290
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
+
299
319
pub fn noop_fold_use_tree < T : Folder > ( use_tree : UseTree , fld : & mut T ) -> UseTree {
300
320
UseTree {
301
321
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
312
332
}
313
333
}
314
334
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
-
323
335
pub fn noop_fold_arm < T : Folder > ( Arm { attrs, pats, guard, body} : Arm ,
324
336
fld : & mut T ) -> Arm {
325
337
Arm {
@@ -824,11 +836,6 @@ pub fn noop_fold_mt<T: Folder>(MutTy {ty, mutbl}: MutTy, folder: &mut T) -> MutT
824
836
}
825
837
}
826
838
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
-
832
839
pub fn noop_fold_block < T : Folder > ( b : P < Block > , folder : & mut T ) -> P < Block > {
833
840
b. map ( |Block { id, stmts, rules, span} | Block {
834
841
id : folder. new_id ( id) ,
@@ -864,7 +871,7 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
864
871
ItemKind :: Ty ( folder. fold_ty ( t) , folder. fold_generics ( generics) )
865
872
}
866
873
ItemKind :: Existential ( bounds, generics) => ItemKind :: Existential (
867
- folder . fold_bounds ( bounds) ,
874
+ fold_bounds ( bounds, folder ) ,
868
875
folder. fold_generics ( generics) ,
869
876
) ,
870
877
ItemKind :: Enum ( enum_definition, generics) => {
@@ -899,12 +906,12 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
899
906
is_auto,
900
907
unsafety,
901
908
folder. fold_generics ( generics) ,
902
- folder . fold_bounds ( bounds) ,
909
+ fold_bounds ( bounds, folder ) ,
903
910
items. move_flat_map ( |item| folder. fold_trait_item ( item) ) ,
904
911
) ,
905
912
ItemKind :: TraitAlias ( generics, bounds) => ItemKind :: TraitAlias (
906
913
folder. fold_generics ( generics) ,
907
- folder . fold_bounds ( bounds) ) ,
914
+ fold_bounds ( bounds, folder ) ) ,
908
915
ItemKind :: Mac ( m) => ItemKind :: Mac ( folder. fold_mac ( m) ) ,
909
916
ItemKind :: MacroDef ( def) => ItemKind :: MacroDef ( folder. fold_macro_def ( def) ) ,
910
917
}
@@ -922,11 +929,11 @@ pub fn noop_fold_trait_item<T: Folder>(i: TraitItem, folder: &mut T) -> SmallVec
922
929
default . map( |x| folder. fold_expr( x) ) )
923
930
}
924
931
TraitItemKind :: Method ( sig, body) => {
925
- TraitItemKind :: Method ( noop_fold_method_sig ( sig, folder) ,
932
+ TraitItemKind :: Method ( fold_method_sig ( sig, folder) ,
926
933
body. map( |x| folder. fold_block( x) ) )
927
934
}
928
935
TraitItemKind :: Type ( bounds, default ) => {
929
- TraitItemKind :: Type ( folder . fold_bounds( bounds) ,
936
+ TraitItemKind :: Type ( fold_bounds( bounds, folder ) ,
930
937
default . map( |x| folder. fold_ty( x) ) )
931
938
}
932
939
TraitItemKind :: Macro ( mac) => {
@@ -951,12 +958,12 @@ pub fn noop_fold_impl_item<T: Folder>(i: ImplItem, folder: &mut T)-> SmallVec<[I
951
958
ImplItemKind :: Const ( folder. fold_ty( ty) , folder. fold_expr( expr) )
952
959
}
953
960
ImplItemKind :: Method ( sig, body) => {
954
- ImplItemKind :: Method ( noop_fold_method_sig ( sig, folder) ,
961
+ ImplItemKind :: Method ( fold_method_sig ( sig, folder) ,
955
962
folder. fold_block( body) )
956
963
}
957
964
ImplItemKind :: Type ( ty) => ImplItemKind :: Type ( folder. fold_ty( ty) ) ,
958
965
ImplItemKind :: Existential ( bounds) => {
959
- ImplItemKind :: Existential ( folder . fold_bounds( bounds) )
966
+ ImplItemKind :: Existential ( fold_bounds( bounds, folder ) )
960
967
} ,
961
968
ImplItemKind :: Macro ( mac) => ImplItemKind :: Macro ( folder. fold_mac( mac) )
962
969
} ,
@@ -1047,13 +1054,6 @@ pub fn noop_fold_foreign_item<T: Folder>(ni: ForeignItem, folder: &mut T)
1047
1054
} ]
1048
1055
}
1049
1056
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
-
1057
1057
pub fn noop_fold_pat < T : Folder > ( p : P < Pat > , folder : & mut T ) -> P < Pat > {
1058
1058
p. map ( |Pat { id, node, span} | Pat {
1059
1059
id : folder. new_id ( id) ,
@@ -1125,15 +1125,15 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
1125
1125
ExprKind :: ObsoleteInPlace ( folder. fold_expr ( a) , folder. fold_expr ( b) )
1126
1126
}
1127
1127
ExprKind :: Array ( exprs) => {
1128
- ExprKind :: Array ( folder . fold_exprs ( exprs) )
1128
+ ExprKind :: Array ( fold_exprs ( exprs, folder ) )
1129
1129
}
1130
1130
ExprKind :: Repeat ( expr, count) => {
1131
1131
ExprKind :: Repeat ( folder. fold_expr ( expr) , folder. fold_anon_const ( count) )
1132
1132
}
1133
- ExprKind :: Tup ( exprs) => ExprKind :: Tup ( folder . fold_exprs ( exprs) ) ,
1133
+ ExprKind :: Tup ( exprs) => ExprKind :: Tup ( fold_exprs ( exprs, folder ) ) ,
1134
1134
ExprKind :: Call ( f, args) => {
1135
1135
ExprKind :: Call ( folder. fold_expr ( f) ,
1136
- folder . fold_exprs ( args) )
1136
+ fold_exprs ( args, folder ) )
1137
1137
}
1138
1138
ExprKind :: MethodCall ( seg, args) => {
1139
1139
ExprKind :: MethodCall (
@@ -1144,7 +1144,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
1144
1144
args. map ( |args| folder. fold_generic_args ( args) )
1145
1145
} ) ,
1146
1146
} ,
1147
- folder . fold_exprs ( args) )
1147
+ fold_exprs ( args, folder ) )
1148
1148
}
1149
1149
ExprKind :: Binary ( binop, lhs, rhs) => {
1150
1150
ExprKind :: Binary ( binop,
@@ -1294,10 +1294,6 @@ pub fn noop_fold_opt_expr<T: Folder>(e: P<Expr>, folder: &mut T) -> Option<P<Exp
1294
1294
Some ( folder. fold_expr ( e) )
1295
1295
}
1296
1296
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
-
1301
1297
pub fn noop_fold_stmt < T : Folder > ( Stmt { node, span, id} : Stmt , folder : & mut T ) -> SmallVec < [ Stmt ; 1 ] >
1302
1298
{
1303
1299
let id = folder. new_id ( id) ;
0 commit comments