summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2018-05-29 22:56:37 +0300
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2018-05-30 20:29:38 +0300
commita1433f2f88217d35f8f75650e07ff4abb1c6c625 (patch)
tree53c028bbeb9c7d3c548ce5eca1d50f9243c7f50b
parentAuto merge of #50955 - steveklabnik:update-libbacktrace, r=alexcrichton (diff)
downloadgrust-a1433f2f88217d35f8f75650e07ff4abb1c6c625.tar.gz
grust-a1433f2f88217d35f8f75650e07ff4abb1c6c625.tar.bz2
grust-a1433f2f88217d35f8f75650e07ff4abb1c6c625.tar.xz
syntax: remove overloading of fold_lifetime{,_def}{,s}.
-rw-r--r--src/libsyntax/fold.rs74
1 files changed, 20 insertions, 54 deletions
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index ecb4332379..2f209b347a 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -205,14 +205,6 @@ pub trait Folder : Sized {
205 noop_fold_label(label, self) 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 fn fold_attribute(&mut self, at: Attribute) -> Option<Attribute> { 208 fn fold_attribute(&mut self, at: Attribute) -> Option<Attribute> {
217 noop_fold_attribute(at, self) 209 noop_fold_attribute(at, self)
218 } 210 }
@@ -237,14 +229,6 @@ pub trait Folder : Sized {
237 noop_fold_variant_data(vdata, self) 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 fn fold_ty_param(&mut self, tp: TyParam) -> TyParam { 232 fn fold_ty_param(&mut self, tp: TyParam) -> TyParam {
249 noop_fold_ty_param(tp, self) 233 noop_fold_ty_param(tp, self)
250 } 234 }
@@ -273,10 +257,6 @@ pub trait Folder : Sized {
273 noop_fold_interpolated(nt, self) 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 fn fold_opt_bounds(&mut self, b: Option<TyParamBounds>) 260 fn fold_opt_bounds(&mut self, b: Option<TyParamBounds>)
281 -> Option<TyParamBounds> { 261 -> Option<TyParamBounds> {
282 noop_fold_opt_bounds(b, self) 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 TyKind::Slice(ty) => TyKind::Slice(fld.fold_ty(ty)), 356 TyKind::Slice(ty) => TyKind::Slice(fld.fold_ty(ty)),
377 TyKind::Ptr(mt) => TyKind::Ptr(fld.fold_mt(mt)), 357 TyKind::Ptr(mt) => TyKind::Ptr(fld.fold_mt(mt)),
378 TyKind::Rptr(region, mt) => { 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 TyKind::BareFn(f) => { 361 TyKind::BareFn(f) => {
382 TyKind::BareFn(f.map(|BareFnTy {generic_params, unsafety, abi, decl}| BareFnTy { 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 -> AngleBracketedParameterData 458 -> AngleBracketedParameterData
479{ 459{
480 let AngleBracketedParameterData { lifetimes, types, bindings, span } = data; 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 types: types.move_map(|ty| fld.fold_ty(ty)), 462 types: types.move_map(|ty| fld.fold_ty(ty)),
483 bindings: bindings.move_map(|b| fld.fold_ty_binding(b)), 463 bindings: bindings.move_map(|b| fld.fold_ty_binding(b)),
484 span: fld.new_span(span) } 464 span: fld.new_span(span) }
@@ -680,7 +660,7 @@ pub fn noop_fold_ty_param_bound<T>(tpb: TyParamBound, fld: &mut T)
680 where T: Folder { 660 where T: Folder {
681 match tpb { 661 match tpb {
682 TraitTyParamBound(ty, modifier) => TraitTyParamBound(fld.fold_poly_trait_ref(ty), modifier), 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
702pub fn noop_fold_generic_param<T: Folder>(param: GenericParam, fld: &mut T) -> GenericParam { 682pub fn noop_fold_generic_param<T: Folder>(param: GenericParam, fld: &mut T) -> GenericParam {
703 match param { 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 GenericParam::Type(t) => GenericParam::Type(fld.fold_ty_param(t)), 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
722pub fn noop_fold_lifetime<T: Folder>(l: Lifetime, fld: &mut T) -> Lifetime { 715fn noop_fold_lifetime<T: Folder>(l: Lifetime, fld: &mut T) -> Lifetime {
723 Lifetime { 716 Lifetime {
724 id: fld.new_id(l.id), 717 id: fld.new_id(l.id),
725 ident: fld.fold_ident(l.ident), 718 ident: fld.fold_ident(l.ident),
726 } 719 }
727} 720}
728 721
729pub 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
742pub 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
746pub 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
751pub 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
756pub fn noop_fold_generics<T: Folder>(Generics { params, where_clause, span }: Generics, 722pub fn noop_fold_generics<T: Folder>(Generics { params, where_clause, span }: Generics,
757 fld: &mut T) -> Generics { 723 fld: &mut T) -> Generics {
758 Generics { 724 Generics {
@@ -796,8 +762,8 @@ pub fn noop_fold_where_predicate<T: Folder>(
796 span}) => { 762 span}) => {
797 ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate { 763 ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
798 span: fld.new_span(span), 764 span: fld.new_span(span),
799 lifetime: fld.fold_lifetime(lifetime), 765 lifetime: noop_fold_lifetime(lifetime, fld),
800 bounds: bounds.move_map(|bound| fld.fold_lifetime(bound)) 766 bounds: bounds.move_map(|bound| noop_fold_lifetime(bound, fld))
801 }) 767 })
802 } 768 }
803 ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{id, 769 ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{id,