@@ -205,14 +205,6 @@ pub trait Folder : Sized {
205
205
noop_fold_label ( label, self )
206
206
}
207
207
208
- fn fold_lifetime ( & mut self , l : Lifetime ) -> Lifetime {
209
- noop_fold_lifetime ( l, self )
210
- }
211
-
212
- fn fold_lifetime_def ( & mut self , l : LifetimeDef ) -> LifetimeDef {
213
- noop_fold_lifetime_def ( l, self )
214
- }
215
-
216
208
fn fold_attribute ( & mut self , at : Attribute ) -> Option < Attribute > {
217
209
noop_fold_attribute ( at, self )
218
210
}
@@ -237,14 +229,6 @@ pub trait Folder : Sized {
237
229
noop_fold_variant_data ( vdata, self )
238
230
}
239
231
240
- fn fold_lifetimes ( & mut self , lts : Vec < Lifetime > ) -> Vec < Lifetime > {
241
- noop_fold_lifetimes ( lts, self )
242
- }
243
-
244
- fn fold_lifetime_defs ( & mut self , lts : Vec < LifetimeDef > ) -> Vec < LifetimeDef > {
245
- noop_fold_lifetime_defs ( lts, self )
246
- }
247
-
248
232
fn fold_ty_param ( & mut self , tp : TyParam ) -> TyParam {
249
233
noop_fold_ty_param ( tp, self )
250
234
}
@@ -273,10 +257,6 @@ pub trait Folder : Sized {
273
257
noop_fold_interpolated ( nt, self )
274
258
}
275
259
276
- fn fold_opt_lifetime ( & mut self , o_lt : Option < Lifetime > ) -> Option < Lifetime > {
277
- noop_fold_opt_lifetime ( o_lt, self )
278
- }
279
-
280
260
fn fold_opt_bounds ( & mut self , b : Option < TyParamBounds > )
281
261
-> Option < TyParamBounds > {
282
262
noop_fold_opt_bounds ( b, self )
@@ -376,7 +356,7 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
376
356
TyKind :: Slice ( ty) => TyKind :: Slice ( fld. fold_ty ( ty) ) ,
377
357
TyKind :: Ptr ( mt) => TyKind :: Ptr ( fld. fold_mt ( mt) ) ,
378
358
TyKind :: Rptr ( region, mt) => {
379
- TyKind :: Rptr ( fld . fold_opt_lifetime ( region ) , fld. fold_mt ( mt) )
359
+ TyKind :: Rptr ( region . map ( |lt| noop_fold_lifetime ( lt , fld ) ) , fld. fold_mt ( mt) )
380
360
}
381
361
TyKind :: BareFn ( f) => {
382
362
TyKind :: BareFn ( f. map ( |BareFnTy { generic_params, unsafety, abi, decl} | BareFnTy {
@@ -478,7 +458,7 @@ pub fn noop_fold_angle_bracketed_parameter_data<T: Folder>(data: AngleBracketedP
478
458
-> AngleBracketedParameterData
479
459
{
480
460
let AngleBracketedParameterData { lifetimes, types, bindings, span } = data;
481
- AngleBracketedParameterData { lifetimes : fld . fold_lifetimes ( lifetimes ) ,
461
+ AngleBracketedParameterData { lifetimes : lifetimes . move_map ( |l| noop_fold_lifetime ( l , fld ) ) ,
482
462
types : types. move_map ( |ty| fld. fold_ty ( ty) ) ,
483
463
bindings : bindings. move_map ( |b| fld. fold_ty_binding ( b) ) ,
484
464
span : fld. new_span ( span) }
@@ -680,7 +660,7 @@ pub fn noop_fold_ty_param_bound<T>(tpb: TyParamBound, fld: &mut T)
680
660
where T : Folder {
681
661
match tpb {
682
662
TraitTyParamBound ( ty, modifier) => TraitTyParamBound ( fld. fold_poly_trait_ref ( ty) , modifier) ,
683
- RegionTyParamBound ( lifetime) => RegionTyParamBound ( fld . fold_lifetime ( lifetime) ) ,
663
+ RegionTyParamBound ( lifetime) => RegionTyParamBound ( noop_fold_lifetime ( lifetime, fld ) ) ,
684
664
}
685
665
}
686
666
@@ -701,7 +681,20 @@ pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
701
681
702
682
pub fn noop_fold_generic_param < T : Folder > ( param : GenericParam , fld : & mut T ) -> GenericParam {
703
683
match param {
704
- GenericParam :: Lifetime ( l) => GenericParam :: Lifetime ( fld. fold_lifetime_def ( l) ) ,
684
+ GenericParam :: Lifetime ( l) => {
685
+ let attrs: Vec < _ > = l. attrs . into ( ) ;
686
+ GenericParam :: Lifetime ( LifetimeDef {
687
+ attrs : attrs. into_iter ( )
688
+ . flat_map ( |x| fld. fold_attribute ( x) . into_iter ( ) )
689
+ . collect :: < Vec < _ > > ( )
690
+ . into ( ) ,
691
+ lifetime : Lifetime {
692
+ id : fld. new_id ( l. lifetime . id ) ,
693
+ ident : fld. fold_ident ( l. lifetime . ident ) ,
694
+ } ,
695
+ bounds : l. bounds . move_map ( |l| noop_fold_lifetime ( l, fld) ) ,
696
+ } )
697
+ }
705
698
GenericParam :: Type ( t) => GenericParam :: Type ( fld. fold_ty_param ( t) ) ,
706
699
}
707
700
}
@@ -719,40 +712,13 @@ pub fn noop_fold_label<T: Folder>(label: Label, fld: &mut T) -> Label {
719
712
}
720
713
}
721
714
722
- pub fn noop_fold_lifetime < T : Folder > ( l : Lifetime , fld : & mut T ) -> Lifetime {
715
+ fn noop_fold_lifetime < T : Folder > ( l : Lifetime , fld : & mut T ) -> Lifetime {
723
716
Lifetime {
724
717
id : fld. new_id ( l. id ) ,
725
718
ident : fld. fold_ident ( l. ident ) ,
726
719
}
727
720
}
728
721
729
- pub fn noop_fold_lifetime_def < T : Folder > ( l : LifetimeDef , fld : & mut T )
730
- -> LifetimeDef {
731
- let attrs: Vec < _ > = l. attrs . into ( ) ;
732
- LifetimeDef {
733
- attrs : attrs. into_iter ( )
734
- . flat_map ( |x| fld. fold_attribute ( x) . into_iter ( ) )
735
- . collect :: < Vec < _ > > ( )
736
- . into ( ) ,
737
- lifetime : fld. fold_lifetime ( l. lifetime ) ,
738
- bounds : fld. fold_lifetimes ( l. bounds ) ,
739
- }
740
- }
741
-
742
- pub fn noop_fold_lifetimes < T : Folder > ( lts : Vec < Lifetime > , fld : & mut T ) -> Vec < Lifetime > {
743
- lts. move_map ( |l| fld. fold_lifetime ( l) )
744
- }
745
-
746
- pub fn noop_fold_lifetime_defs < T : Folder > ( lts : Vec < LifetimeDef > , fld : & mut T )
747
- -> Vec < LifetimeDef > {
748
- lts. move_map ( |l| fld. fold_lifetime_def ( l) )
749
- }
750
-
751
- pub fn noop_fold_opt_lifetime < T : Folder > ( o_lt : Option < Lifetime > , fld : & mut T )
752
- -> Option < Lifetime > {
753
- o_lt. map ( |lt| fld. fold_lifetime ( lt) )
754
- }
755
-
756
722
pub fn noop_fold_generics < T : Folder > ( Generics { params, where_clause, span } : Generics ,
757
723
fld : & mut T ) -> Generics {
758
724
Generics {
@@ -796,8 +762,8 @@ pub fn noop_fold_where_predicate<T: Folder>(
796
762
span} ) => {
797
763
ast:: WherePredicate :: RegionPredicate ( ast:: WhereRegionPredicate {
798
764
span : fld. new_span ( span) ,
799
- lifetime : fld . fold_lifetime ( lifetime) ,
800
- bounds : bounds. move_map ( |bound| fld . fold_lifetime ( bound) )
765
+ lifetime : noop_fold_lifetime ( lifetime, fld ) ,
766
+ bounds : bounds. move_map ( |bound| noop_fold_lifetime ( bound, fld ) )
801
767
} )
802
768
}
803
769
ast:: WherePredicate :: EqPredicate ( ast:: WhereEqPredicate { id,
0 commit comments