Skip to content

Commit a1433f2

Browse files
committed
syntax: remove overloading of fold_lifetime{,_def}{,s}.
1 parent 74d0939 commit a1433f2

File tree

1 file changed

+20
-54
lines changed

1 file changed

+20
-54
lines changed

src/libsyntax/fold.rs

+20-54
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,6 @@ pub trait Folder : Sized {
205205
noop_fold_label(label, self)
206206
}
207207

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-
216208
fn fold_attribute(&mut self, at: Attribute) -> Option<Attribute> {
217209
noop_fold_attribute(at, self)
218210
}
@@ -237,14 +229,6 @@ pub trait Folder : Sized {
237229
noop_fold_variant_data(vdata, self)
238230
}
239231

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-
248232
fn fold_ty_param(&mut self, tp: TyParam) -> TyParam {
249233
noop_fold_ty_param(tp, self)
250234
}
@@ -273,10 +257,6 @@ pub trait Folder : Sized {
273257
noop_fold_interpolated(nt, self)
274258
}
275259

276-
fn fold_opt_lifetime(&mut self, o_lt: Option<Lifetime>) -> Option<Lifetime> {
277-
noop_fold_opt_lifetime(o_lt, self)
278-
}
279-
280260
fn fold_opt_bounds(&mut self, b: Option<TyParamBounds>)
281261
-> Option<TyParamBounds> {
282262
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> {
376356
TyKind::Slice(ty) => TyKind::Slice(fld.fold_ty(ty)),
377357
TyKind::Ptr(mt) => TyKind::Ptr(fld.fold_mt(mt)),
378358
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))
380360
}
381361
TyKind::BareFn(f) => {
382362
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
478458
-> AngleBracketedParameterData
479459
{
480460
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)),
482462
types: types.move_map(|ty| fld.fold_ty(ty)),
483463
bindings: bindings.move_map(|b| fld.fold_ty_binding(b)),
484464
span: fld.new_span(span) }
@@ -680,7 +660,7 @@ pub fn noop_fold_ty_param_bound<T>(tpb: TyParamBound, fld: &mut T)
680660
where T: Folder {
681661
match tpb {
682662
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)),
684664
}
685665
}
686666

@@ -701,7 +681,20 @@ pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
701681

702682
pub fn noop_fold_generic_param<T: Folder>(param: GenericParam, fld: &mut T) -> GenericParam {
703683
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+
}
705698
GenericParam::Type(t) => GenericParam::Type(fld.fold_ty_param(t)),
706699
}
707700
}
@@ -719,40 +712,13 @@ pub fn noop_fold_label<T: Folder>(label: Label, fld: &mut T) -> Label {
719712
}
720713
}
721714

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 {
723716
Lifetime {
724717
id: fld.new_id(l.id),
725718
ident: fld.fold_ident(l.ident),
726719
}
727720
}
728721

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-
756722
pub fn noop_fold_generics<T: Folder>(Generics { params, where_clause, span }: Generics,
757723
fld: &mut T) -> Generics {
758724
Generics {
@@ -796,8 +762,8 @@ pub fn noop_fold_where_predicate<T: Folder>(
796762
span}) => {
797763
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
798764
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))
801767
})
802768
}
803769
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{id,

0 commit comments

Comments
 (0)