Rename fold_subitems_with to super_fold_with

This commit is contained in:
Jeffrey Seyfried 2016-01-06 02:01:28 +00:00
parent 76021d84b3
commit 6327563963
9 changed files with 183 additions and 184 deletions

View File

@ -318,7 +318,7 @@ impl<'cx, 'tcx> ty::fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
}
}
_ => {
t.fold_subitems_with(self)
t.super_fold_with(self)
}
}
}

View File

@ -168,7 +168,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
ty::TyTuple(..) |
ty::TyProjection(..) |
ty::TyParam(..) => {
t.fold_subitems_with(self)
t.super_fold_with(self)
}
}
}

View File

@ -39,7 +39,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeResolver<'a, 'tcx
t // micro-optimize -- if there is nothing in this type that this fold affects...
} else {
let t0 = self.infcx.shallow_resolve(t);
t0.fold_subitems_with(self)
t0.super_fold_with(self)
}
}
}
@ -67,7 +67,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver
t // micro-optimize -- if there is nothing in this type that this fold affects...
} else {
let t0 = self.infcx.shallow_resolve(t);
t0.fold_subitems_with(self)
t0.super_fold_with(self)
}
}
@ -132,7 +132,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
t));
}
_ => {
t.fold_subitems_with(self)
t.super_fold_with(self)
}
}
}

View File

@ -674,7 +674,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
self.ty_for_param(p, t)
}
_ => {
t.fold_subitems_with(self)
t.super_fold_with(self)
}
};

View File

@ -273,7 +273,7 @@ impl<'a,'b,'tcx> TypeFolder<'tcx> for AssociatedTypeNormalizer<'a,'b,'tcx> {
// normalize it when we instantiate those bound regions (which
// should occur eventually).
let ty = ty.fold_subitems_with(self);
let ty = ty.super_fold_with(self);
match ty.sty {
ty::TyProjection(ref data) if !data.has_escaping_regions() => { // (*)

View File

@ -132,7 +132,7 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx, O>
{
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Obligation<'tcx, O> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
traits::Obligation {
cause: self.cause.clone(),
recursion_depth: self.recursion_depth,
@ -140,13 +140,13 @@ impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.predicate.visit_with(visitor)
}
}
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableImplData<'tcx, N> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableImplData<'tcx, N> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
traits::VtableImplData {
impl_def_id: self.impl_def_id,
substs: self.substs.fold_with(folder),
@ -154,13 +154,13 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableImplData<
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.substs.visit_with(visitor) || self.nested.visit_with(visitor)
}
}
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableClosureData<'tcx, N> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableClosureData<'tcx, N> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
traits::VtableClosureData {
closure_def_id: self.closure_def_id,
substs: self.substs.fold_with(folder),
@ -168,51 +168,51 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableClosureDa
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.substs.visit_with(visitor) || self.nested.visit_with(visitor)
}
}
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableDefaultImplData<N> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableDefaultImplData<N> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
traits::VtableDefaultImplData {
trait_def_id: self.trait_def_id,
nested: self.nested.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.nested.visit_with(visitor)
}
}
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableBuiltinData<N> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableBuiltinData<N> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
traits::VtableBuiltinData {
nested: self.nested.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.nested.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for traits::VtableObjectData<'tcx> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableObjectData<'tcx> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
traits::VtableObjectData {
upcast_trait_ref: self.upcast_trait_ref.fold_with(folder),
vtable_base: self.vtable_base
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.upcast_trait_ref.visit_with(visitor)
}
}
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Vtable<'tcx, N> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
match *self {
traits::VtableImpl(ref v) => traits::VtableImpl(v.fold_with(folder)),
traits::VtableDefaultImpl(ref t) => traits::VtableDefaultImpl(t.fold_with(folder)),
@ -228,7 +228,7 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N>
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
match *self {
traits::VtableImpl(ref v) => v.visit_with(visitor),
traits::VtableDefaultImpl(ref t) => t.visit_with(visitor),
@ -242,14 +242,14 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N>
}
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Normalized<'tcx, T> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
Normalized {
value: self.value.fold_with(folder),
obligations: self.obligations.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.value.visit_with(visitor) || self.obligations.visit_with(visitor)
}
}

View File

@ -14,18 +14,18 @@
//! instance of a "folder" (a type which implements `TypeFolder`). Then
//! the setup is intended to be:
//!
//! T.fold_with(F) --calls--> F.fold_T(T) --calls--> T.fold_subitems_with(F)
//! T.fold_with(F) --calls--> F.fold_T(T) --calls--> T.super_fold_with(F)
//!
//! This way, when you define a new folder F, you can override
//! `fold_T()` to customize the behavior, and invoke `T.fold_subitems_with()`
//! `fold_T()` to customize the behavior, and invoke `T.super_fold_with()`
//! to get the original behavior. Meanwhile, to actually fold
//! something, you can just write `T.fold_with(F)`, which is
//! convenient. (Note that `fold_with` will also transparently handle
//! things like a `Vec<T>` where T is foldable and so on.)
//!
//! In this ideal setup, the only function that actually *does*
//! anything is `T.fold_subitems_with()`, which traverses the type `T`.
//! Moreover, `T.fold_subitems_with()` should only ever call `T.fold_with()`.
//! anything is `T.super_fold_with()`, which traverses the type `T`.
//! Moreover, `T.super_fold_with()` should only ever call `T.fold_with()`.
//!
//! In some cases, we follow a degenerate pattern where we do not have
//! a `fold_T` method. Instead, `T.fold_with` traverses the structure directly.
@ -35,7 +35,7 @@
//! proper thing.
//!
//! A `TypeFoldable` T can also be visited by a `TypeVisitor` V using similar setup:
//! T.visit_with(V) --calls--> V.visit_T(T) --calls--> T.visit_subitems_with(V).
//! T.visit_with(V) --calls--> V.visit_T(T) --calls--> T.super_visit_with(V).
//! These methods return true to indicate that the visitor has found what it is looking for
//! and does not need to visit anything else.
@ -50,14 +50,14 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
/// The TypeFoldable trait is implemented for every type that can be folded.
/// Basically, every type that has a corresponding method in TypeFolder.
pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self;
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
self.fold_with(folder)
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self;
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
self.super_fold_with(folder)
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool;
fn visit_subitems_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.visit_with(visitor)
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool;
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.super_visit_with(visitor)
}
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
@ -131,64 +131,64 @@ pub trait TypeFolder<'tcx> : Sized {
where T : TypeFoldable<'tcx>
{
// FIXME(#20526) this should replace `enter_region_binder`/`exit_region_binder`.
t.fold_subitems_with(self)
t.super_fold_with(self)
}
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
t.fold_subitems_with(self)
t.super_fold_with(self)
}
fn fold_mt(&mut self, t: &ty::TypeAndMut<'tcx>) -> ty::TypeAndMut<'tcx> {
t.fold_subitems_with(self)
t.super_fold_with(self)
}
fn fold_trait_ref(&mut self, t: &ty::TraitRef<'tcx>) -> ty::TraitRef<'tcx> {
t.fold_subitems_with(self)
t.super_fold_with(self)
}
fn fold_substs(&mut self,
substs: &subst::Substs<'tcx>)
-> subst::Substs<'tcx> {
substs.fold_subitems_with(self)
substs.super_fold_with(self)
}
fn fold_fn_sig(&mut self,
sig: &ty::FnSig<'tcx>)
-> ty::FnSig<'tcx> {
sig.fold_subitems_with(self)
sig.super_fold_with(self)
}
fn fold_output(&mut self,
output: &ty::FnOutput<'tcx>)
-> ty::FnOutput<'tcx> {
output.fold_subitems_with(self)
output.super_fold_with(self)
}
fn fold_bare_fn_ty(&mut self,
fty: &ty::BareFnTy<'tcx>)
-> ty::BareFnTy<'tcx>
{
fty.fold_subitems_with(self)
fty.super_fold_with(self)
}
fn fold_closure_ty(&mut self,
fty: &ty::ClosureTy<'tcx>)
-> ty::ClosureTy<'tcx> {
fty.fold_subitems_with(self)
fty.super_fold_with(self)
}
fn fold_region(&mut self, r: ty::Region) -> ty::Region {
r.fold_subitems_with(self)
r.super_fold_with(self)
}
fn fold_existential_bounds(&mut self, s: &ty::ExistentialBounds<'tcx>)
-> ty::ExistentialBounds<'tcx> {
s.fold_subitems_with(self)
s.super_fold_with(self)
}
fn fold_autoref(&mut self, ar: &adjustment::AutoRef<'tcx>)
-> adjustment::AutoRef<'tcx> {
ar.fold_subitems_with(self)
ar.super_fold_with(self)
}
}
@ -197,11 +197,11 @@ pub trait TypeVisitor<'tcx> : Sized {
fn exit_region_binder(&mut self) { }
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
t.visit_subitems_with(self)
t.super_visit_with(self)
}
fn visit_region(&mut self, r: ty::Region) -> bool {
r.visit_subitems_with(self)
r.super_visit_with(self)
}
}
@ -219,7 +219,7 @@ impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where
fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
let t1 = ty.fold_subitems_with(self);
let t1 = ty.super_fold_with(self);
(self.fldop)(t1)
}
}
@ -447,7 +447,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx>
return t;
}
t.fold_subitems_with(self)
t.super_fold_with(self)
}
fn fold_region(&mut self, r: ty::Region) -> ty::Region {
@ -498,7 +498,7 @@ impl<'tcx> ty::ctxt<'tcx> {
Some(u) => return u
}
let t_norm = ty.fold_subitems_with(self);
let t_norm = ty.super_fold_with(self);
self.tcx().normalized_cache.borrow_mut().insert(ty, t_norm);
return t_norm;
}
@ -507,7 +507,7 @@ impl<'tcx> ty::ctxt<'tcx> {
where T : TypeFoldable<'tcx>
{
let u = self.tcx().anonymize_late_bound_regions(t);
u.fold_subitems_with(self)
u.super_fold_with(self)
}
fn fold_region(&mut self, r: ty::Region) -> ty::Region {

View File

@ -123,11 +123,11 @@ macro_rules! CopyImpls {
($($ty:ty),+) => {
$(
impl<'tcx> TypeFoldable<'tcx> for $ty {
fn fold_with<F:TypeFolder<'tcx>>(&self, _: &mut F) -> $ty {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, _: &mut F) -> $ty {
*self
}
fn visit_with<F: TypeVisitor<'tcx>>(&self, _: &mut F) -> bool {
fn super_visit_with<F: TypeVisitor<'tcx>>(&self, _: &mut F) -> bool {
false
}
}
@ -138,69 +138,69 @@ macro_rules! CopyImpls {
CopyImpls! { (), hir::Unsafety, abi::Abi }
impl<'tcx, T:TypeFoldable<'tcx>, U:TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> (T, U) {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> (T, U) {
(self.0.fold_with(folder), self.1.fold_with(folder))
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.0.visit_with(visitor) || self.1.visit_with(visitor)
}
}
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Option<T> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Option<T> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
self.as_ref().map(|t| t.fold_with(folder))
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.iter().any(|t| t.visit_with(visitor))
}
}
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Rc<T> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Rc<T> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
Rc::new((**self).fold_with(folder))
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
(**self).visit_with(visitor)
}
}
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<T> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Box<T> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
let content: T = (**self).fold_with(folder);
box content
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
(**self).visit_with(visitor)
}
}
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec<T> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Vec<T> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
self.iter().map(|t| t.fold_with(folder)).collect()
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.iter().any(|t| t.visit_with(visitor))
}
}
impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Binder<T> {
folder.fold_binder(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.enter_region_binder();
let result = ty::Binder(self.0.fold_with(folder));
folder.exit_region_binder();
result
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_binder(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
visitor.enter_region_binder();
if self.0.visit_with(visitor) { return true }
visitor.exit_region_binder();
@ -209,17 +209,17 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
}
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for P<[T]> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> P<[T]> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
self.iter().map(|t| t.fold_with(folder)).collect()
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.iter().any(|t| t.visit_with(visitor))
}
}
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for VecPerParamSpace<T> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> VecPerParamSpace<T> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
// Things in the Fn space take place under an additional level
// of region binding relative to the other spaces. This is
@ -240,7 +240,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for VecPerParamSpace<T> {
result
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
let mut entered_region_binder = false;
let result = self.iter_enumerated().any(|(space, index, t)| {
if space == subst::FnSpace && index == 0 {
@ -257,24 +257,20 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for VecPerParamSpace<T> {
}
impl<'tcx> TypeFoldable<'tcx> for ty::TraitTy<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::TraitTy {
principal: self.principal.fold_with(folder),
bounds: self.bounds.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.principal.visit_with(visitor) || self.bounds.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Ty<'tcx> {
folder.fold_ty(*self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
let sty = match self.sty {
ty::TyBox(typ) => ty::TyBox(typ.fold_with(folder)),
ty::TyRawPtr(ref tm) => ty::TyRawPtr(tm.fold_with(folder)),
@ -309,11 +305,11 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
folder.tcx().mk_ty(sty)
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
visitor.visit_ty(self)
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_ty(*self)
}
fn visit_subitems_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
match self.sty {
ty::TyBox(typ) => typ.visit_with(visitor),
ty::TyRawPtr(ref tm) => tm.visit_with(visitor),
@ -332,30 +328,30 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
ty::TyParam(..) => false,
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
visitor.visit_ty(self)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::BareFnTy<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::BareFnTy<'tcx> {
folder.fold_bare_fn_ty(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::BareFnTy { sig: self.sig.fold_with(folder),
abi: self.abi,
unsafety: self.unsafety }
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_bare_fn_ty(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.sig.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::ClosureTy<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ClosureTy<'tcx> {
folder.fold_closure_ty(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::ClosureTy {
sig: self.sig.fold_with(folder),
unsafety: self.unsafety,
@ -363,38 +359,42 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ClosureTy<'tcx> {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_closure_ty(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.sig.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::TypeAndMut<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeAndMut<'tcx> {
folder.fold_mt(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::TypeAndMut { ty: self.ty.fold_with(folder), mutbl: self.mutbl }
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_mt(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.ty.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::FnOutput<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::FnOutput<'tcx> {
folder.fold_output(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
match *self {
ty::FnConverging(ref ty) => ty::FnConverging(ty.fold_with(folder)),
ty::FnDiverging => ty::FnDiverging
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_output(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
match *self {
ty::FnConverging(ref ty) => ty.visit_with(visitor),
ty::FnDiverging => false,
@ -403,27 +403,23 @@ impl<'tcx> TypeFoldable<'tcx> for ty::FnOutput<'tcx> {
}
impl<'tcx> TypeFoldable<'tcx> for ty::FnSig<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::FnSig<'tcx> {
folder.fold_fn_sig(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::FnSig { inputs: self.inputs.fold_with(folder),
output: self.output.fold_with(folder),
variadic: self.variadic }
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_fn_sig(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.inputs.visit_with(visitor) || self.output.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::TraitRef<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitRef<'tcx> {
folder.fold_trait_ref(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
let substs = self.substs.fold_with(folder);
ty::TraitRef {
def_id: self.def_id,
@ -431,35 +427,35 @@ impl<'tcx> TypeFoldable<'tcx> for ty::TraitRef<'tcx> {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_trait_ref(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.substs.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::Region {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Region {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> Self {
*self
}
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_region(*self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> Self {
*self
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
false
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
visitor.visit_region(*self)
}
fn visit_subitems_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
false
}
}
impl<'tcx> TypeFoldable<'tcx> for subst::Substs<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> subst::Substs<'tcx> {
folder.fold_substs(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
let regions = match self.regions {
subst::ErasedRegions => subst::ErasedRegions,
subst::NonerasedRegions(ref regions) => {
@ -471,7 +467,11 @@ impl<'tcx> TypeFoldable<'tcx> for subst::Substs<'tcx> {
types: self.types.fold_with(folder) }
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_substs(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.types.visit_with(visitor) || match self.regions {
subst::ErasedRegions => false,
subst::NonerasedRegions(ref regions) => regions.visit_with(visitor),
@ -480,7 +480,7 @@ impl<'tcx> TypeFoldable<'tcx> for subst::Substs<'tcx> {
}
impl<'tcx> TypeFoldable<'tcx> for ty::ClosureSubsts<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ClosureSubsts<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
let func_substs = self.func_substs.fold_with(folder);
ty::ClosureSubsts {
func_substs: folder.tcx().mk_substs(func_substs),
@ -488,29 +488,25 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ClosureSubsts<'tcx> {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.func_substs.visit_with(visitor) || self.upvar_tys.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::ItemSubsts<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ItemSubsts<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::ItemSubsts {
substs: self.substs.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.substs.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::adjustment::AutoRef<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::adjustment::AutoRef<'tcx> {
folder.fold_autoref(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
match *self {
ty::adjustment::AutoPtr(r, m) => {
let r = r.fold_with(folder);
@ -520,7 +516,11 @@ impl<'tcx> TypeFoldable<'tcx> for ty::adjustment::AutoRef<'tcx> {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_autoref(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
match *self {
ty::adjustment::AutoPtr(r, _m) => r.visit_with(visitor),
ty::adjustment::AutoUnsafe(_m) => false,
@ -529,21 +529,17 @@ impl<'tcx> TypeFoldable<'tcx> for ty::adjustment::AutoRef<'tcx> {
}
impl<'tcx> TypeFoldable<'tcx> for ty::BuiltinBounds {
fn fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> ty::BuiltinBounds {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> Self {
*self
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
false
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::ExistentialBounds<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ExistentialBounds<'tcx> {
folder.fold_existential_bounds(self)
}
fn fold_subitems_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::ExistentialBounds {
region_bound: self.region_bound.fold_with(folder),
builtin_bounds: self.builtin_bounds,
@ -551,13 +547,17 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ExistentialBounds<'tcx> {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
folder.fold_existential_bounds(self)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.region_bound.visit_with(visitor) || self.projection_bounds.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::TypeParameterDef<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeParameterDef<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::TypeParameterDef {
name: self.name,
def_id: self.def_id,
@ -569,14 +569,14 @@ impl<'tcx> TypeFoldable<'tcx> for ty::TypeParameterDef<'tcx> {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.default.visit_with(visitor) ||
self.object_lifetime_default.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::ObjectLifetimeDefault {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ObjectLifetimeDefault {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
match *self {
ty::ObjectLifetimeDefault::Ambiguous =>
ty::ObjectLifetimeDefault::Ambiguous,
@ -589,7 +589,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ObjectLifetimeDefault {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
match *self {
ty::ObjectLifetimeDefault::Specific(r) => r.visit_with(visitor),
_ => false,
@ -598,7 +598,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ObjectLifetimeDefault {
}
impl<'tcx> TypeFoldable<'tcx> for ty::RegionParameterDef {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::RegionParameterDef {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::RegionParameterDef {
name: self.name,
def_id: self.def_id,
@ -608,38 +608,38 @@ impl<'tcx> TypeFoldable<'tcx> for ty::RegionParameterDef {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.bounds.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::Generics<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Generics<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::Generics {
types: self.types.fold_with(folder),
regions: self.regions.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.types.visit_with(visitor) || self.regions.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::GenericPredicates<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::GenericPredicates<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::GenericPredicates {
predicates: self.predicates.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.predicates.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Predicate<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
match *self {
ty::Predicate::Trait(ref a) =>
ty::Predicate::Trait(a.fold_with(folder)),
@ -658,7 +658,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
match *self {
ty::Predicate::Trait(ref a) => a.visit_with(visitor),
ty::Predicate::Equate(ref binder) => binder.visit_with(visitor),
@ -672,62 +672,62 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
}
impl<'tcx> TypeFoldable<'tcx> for ty::ProjectionPredicate<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ProjectionPredicate<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::ProjectionPredicate {
projection_ty: self.projection_ty.fold_with(folder),
ty: self.ty.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.projection_ty.visit_with(visitor) || self.ty.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::ProjectionTy<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ProjectionTy<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::ProjectionTy {
trait_ref: self.trait_ref.fold_with(folder),
item_name: self.item_name,
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.trait_ref.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::InstantiatedPredicates<'tcx> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::InstantiatedPredicates<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::InstantiatedPredicates {
predicates: self.predicates.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.predicates.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::EquatePredicate<'tcx> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::EquatePredicate<'tcx> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::EquatePredicate(self.0.fold_with(folder),
self.1.fold_with(folder))
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.0.visit_with(visitor) || self.1.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::TraitPredicate<'tcx> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TraitPredicate<'tcx> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::TraitPredicate {
trait_ref: self.trait_ref.fold_with(folder)
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.trait_ref.visit_with(visitor)
}
}
@ -736,18 +736,18 @@ impl<'tcx,T,U> TypeFoldable<'tcx> for ty::OutlivesPredicate<T,U>
where T : TypeFoldable<'tcx>,
U : TypeFoldable<'tcx>,
{
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::OutlivesPredicate<T,U> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::OutlivesPredicate(self.0.fold_with(folder),
self.1.fold_with(folder))
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.0.visit_with(visitor) || self.1.visit_with(visitor)
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::ClosureUpvar<'tcx> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ClosureUpvar<'tcx> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::ClosureUpvar {
def: self.def,
span: self.span,
@ -755,13 +755,13 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ClosureUpvar<'tcx> {
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.ty.visit_with(visitor)
}
}
impl<'a, 'tcx> TypeFoldable<'tcx> for ty::ParameterEnvironment<'a, 'tcx> where 'tcx: 'a {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ParameterEnvironment<'a, 'tcx> {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::ParameterEnvironment {
tcx: self.tcx,
free_substs: self.free_substs.fold_with(folder),
@ -773,7 +773,7 @@ impl<'a, 'tcx> TypeFoldable<'tcx> for ty::ParameterEnvironment<'a, 'tcx> where '
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.free_substs.visit_with(visitor) ||
self.implicit_region_bound.visit_with(visitor) ||
self.caller_bounds.visit_with(visitor)
@ -781,14 +781,14 @@ impl<'a, 'tcx> TypeFoldable<'tcx> for ty::ParameterEnvironment<'a, 'tcx> where '
}
impl<'tcx> TypeFoldable<'tcx> for ty::TypeScheme<'tcx> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
ty::TypeScheme {
generics: self.generics.fold_with(folder),
ty: self.ty.fold_with(folder),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.generics.visit_with(visitor) || self.ty.visit_with(visitor)
}
}

View File

@ -251,12 +251,11 @@ fn in_binder<'tcx, T, U>(f: &mut fmt::Formatter,
struct TraitAndProjections<'tcx>(ty::TraitRef<'tcx>, Vec<ty::ProjectionPredicate<'tcx>>);
impl<'tcx> TypeFoldable<'tcx> for TraitAndProjections<'tcx> {
fn fold_with<F:ty::fold::TypeFolder<'tcx>>(&self, folder: &mut F)
-> TraitAndProjections<'tcx> {
fn super_fold_with<F:ty::fold::TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
TraitAndProjections(self.0.fold_with(folder), self.1.fold_with(folder))
}
fn visit_with<V: ty::fold::TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
fn super_visit_with<V: ty::fold::TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.0.visit_with(visitor) || self.1.visit_with(visitor)
}
}