2015-09-06 21:51:58 +03:00
|
|
|
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2016-03-22 17:30:57 +02:00
|
|
|
use ty::subst::{self, VecPerParamSpace};
|
|
|
|
use traits;
|
|
|
|
use ty::{self, Lift, TraitRef, Ty, TyCtxt};
|
|
|
|
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
2015-09-06 21:51:58 +03:00
|
|
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
use syntax::abi;
|
2015-12-16 21:44:33 +03:00
|
|
|
use syntax::ptr::P;
|
2015-09-06 21:51:58 +03:00
|
|
|
|
2016-03-29 08:50:44 +03:00
|
|
|
use hir;
|
2015-09-06 21:51:58 +03:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Lift implementations
|
|
|
|
|
|
|
|
impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) {
|
|
|
|
type Lifted = (A::Lifted, B::Lifted);
|
2016-05-03 05:23:22 +03:00
|
|
|
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Self::Lifted> {
|
2015-09-06 21:51:58 +03:00
|
|
|
tcx.lift(&self.0).and_then(|a| tcx.lift(&self.1).map(|b| (a, b)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for [T] {
|
|
|
|
type Lifted = Vec<T::Lifted>;
|
2016-05-03 05:23:22 +03:00
|
|
|
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Self::Lifted> {
|
2015-09-26 02:52:46 +03:00
|
|
|
// type annotation needed to inform `projection_must_outlive`
|
|
|
|
let mut result : Vec<<T as Lift<'tcx>>::Lifted>
|
|
|
|
= Vec::with_capacity(self.len());
|
2015-09-06 21:51:58 +03:00
|
|
|
for x in self {
|
|
|
|
if let Some(value) = tcx.lift(x) {
|
|
|
|
result.push(value);
|
|
|
|
} else {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Some(result)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> Lift<'tcx> for ty::Region {
|
|
|
|
type Lifted = Self;
|
2016-05-03 04:56:42 +03:00
|
|
|
fn lift_to_tcx(&self, _: TyCtxt) -> Option<ty::Region> {
|
2015-09-06 21:51:58 +03:00
|
|
|
Some(*self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, 'tcx> Lift<'tcx> for TraitRef<'a> {
|
|
|
|
type Lifted = TraitRef<'tcx>;
|
2016-05-03 05:23:22 +03:00
|
|
|
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>) -> Option<TraitRef<'tcx>> {
|
2015-09-06 21:51:58 +03:00
|
|
|
tcx.lift(&self.substs).map(|substs| TraitRef {
|
|
|
|
def_id: self.def_id,
|
|
|
|
substs: substs
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
|
|
|
|
type Lifted = ty::TraitPredicate<'tcx>;
|
2016-05-03 05:23:22 +03:00
|
|
|
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>) -> Option<ty::TraitPredicate<'tcx>> {
|
2015-09-06 21:51:58 +03:00
|
|
|
tcx.lift(&self.trait_ref).map(|trait_ref| ty::TraitPredicate {
|
|
|
|
trait_ref: trait_ref
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, 'tcx> Lift<'tcx> for ty::EquatePredicate<'a> {
|
|
|
|
type Lifted = ty::EquatePredicate<'tcx>;
|
2016-05-03 05:23:22 +03:00
|
|
|
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>) -> Option<ty::EquatePredicate<'tcx>> {
|
2015-09-06 21:51:58 +03:00
|
|
|
tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::EquatePredicate(a, b))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx, A: Copy+Lift<'tcx>, B: Copy+Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate<A, B> {
|
|
|
|
type Lifted = ty::OutlivesPredicate<A::Lifted, B::Lifted>;
|
2016-05-03 05:23:22 +03:00
|
|
|
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Self::Lifted> {
|
2015-09-06 21:51:58 +03:00
|
|
|
tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::OutlivesPredicate(a, b))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> {
|
|
|
|
type Lifted = ty::ProjectionPredicate<'tcx>;
|
2016-05-03 05:23:22 +03:00
|
|
|
fn lift_to_tcx<'b>(&self, tcx: TyCtxt<'b, 'tcx, 'tcx>)
|
|
|
|
-> Option<ty::ProjectionPredicate<'tcx>> {
|
2015-09-06 21:51:58 +03:00
|
|
|
tcx.lift(&(self.projection_ty.trait_ref, self.ty)).map(|(trait_ref, ty)| {
|
|
|
|
ty::ProjectionPredicate {
|
|
|
|
projection_ty: ty::ProjectionTy {
|
|
|
|
trait_ref: trait_ref,
|
|
|
|
item_name: self.projection_ty.item_name
|
|
|
|
},
|
|
|
|
ty: ty
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> {
|
|
|
|
type Lifted = ty::Binder<T::Lifted>;
|
2016-05-03 05:23:22 +03:00
|
|
|
fn lift_to_tcx<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Self::Lifted> {
|
2015-09-06 21:51:58 +03:00
|
|
|
tcx.lift(&self.0).map(|x| ty::Binder(x))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// TypeFoldable implementations.
|
|
|
|
//
|
|
|
|
// Ideally, each type should invoke `folder.fold_foo(self)` and
|
|
|
|
// nothing else. In some cases, though, we haven't gotten around to
|
|
|
|
// adding methods on the `folder` yet, and thus the folding is
|
|
|
|
// hard-coded here. This is less-flexible, because folders cannot
|
|
|
|
// override the behavior, but there are a lot of random types and one
|
|
|
|
// can easily refactor the folding into the TypeFolder trait as
|
|
|
|
// needed.
|
|
|
|
|
|
|
|
macro_rules! CopyImpls {
|
|
|
|
($($ty:ty),+) => {
|
|
|
|
$(
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for $ty {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F:TypeFolder<'tcx>>(&self, _: &mut F) -> $ty {
|
2015-09-06 21:51:58 +03:00
|
|
|
*self
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<F: TypeVisitor<'tcx>>(&self, _: &mut F) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
false
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
)+
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyImpls! { (), hir::Unsafety, abi::Abi }
|
|
|
|
|
|
|
|
impl<'tcx, T:TypeFoldable<'tcx>, U:TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> (T, U) {
|
2015-09-06 21:51:58 +03:00
|
|
|
(self.0.fold_with(folder), self.1.fold_with(folder))
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.0.visit_with(visitor) || self.1.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Option<T> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
self.as_ref().map(|t| t.fold_with(folder))
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.iter().any(|t| t.visit_with(visitor))
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Rc<T> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
Rc::new((**self).fold_with(folder))
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
(**self).visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<T> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
let content: T = (**self).fold_with(folder);
|
|
|
|
box content
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
(**self).visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec<T> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
self.iter().map(|t| t.fold_with(folder)).collect()
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.iter().any(|t| t.visit_with(visitor))
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2016-01-08 23:34:05 +00:00
|
|
|
ty::Binder(self.0.fold_with(folder))
|
2015-11-18 09:38:57 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
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 {
|
2016-01-08 23:34:05 +00:00
|
|
|
self.0.visit_with(visitor)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
|
|
|
visitor.visit_binder(self)
|
2015-11-18 09:38:57 +00:00
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
2015-12-16 21:44:33 +03:00
|
|
|
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for P<[T]> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
self.iter().map(|t| t.fold_with(folder)).collect()
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.iter().any(|t| t.visit_with(visitor))
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for VecPerParamSpace<T> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2016-01-08 23:34:05 +00:00
|
|
|
self.map(|elem| elem.fold_with(folder))
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2016-01-08 23:34:05 +00:00
|
|
|
self.iter().any(|elem| elem.visit_with(visitor))
|
2015-11-18 09:38:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::TraitTy<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
ty::TraitTy {
|
|
|
|
principal: self.principal.fold_with(folder),
|
|
|
|
bounds: self.bounds.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.principal.visit_with(visitor) || self.bounds.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
let sty = match self.sty {
|
|
|
|
ty::TyBox(typ) => ty::TyBox(typ.fold_with(folder)),
|
|
|
|
ty::TyRawPtr(ref tm) => ty::TyRawPtr(tm.fold_with(folder)),
|
|
|
|
ty::TyArray(typ, sz) => ty::TyArray(typ.fold_with(folder), sz),
|
|
|
|
ty::TySlice(typ) => ty::TySlice(typ.fold_with(folder)),
|
|
|
|
ty::TyEnum(tid, ref substs) => {
|
|
|
|
let substs = substs.fold_with(folder);
|
|
|
|
ty::TyEnum(tid, folder.tcx().mk_substs(substs))
|
|
|
|
}
|
|
|
|
ty::TyTrait(ref trait_ty) => ty::TyTrait(trait_ty.fold_with(folder)),
|
|
|
|
ty::TyTuple(ref ts) => ty::TyTuple(ts.fold_with(folder)),
|
2016-02-16 18:36:41 +02:00
|
|
|
ty::TyFnDef(def_id, substs, ref f) => {
|
|
|
|
let substs = substs.fold_with(folder);
|
2015-11-18 09:38:57 +00:00
|
|
|
let bfn = f.fold_with(folder);
|
2016-02-16 18:36:41 +02:00
|
|
|
ty::TyFnDef(def_id,
|
|
|
|
folder.tcx().mk_substs(substs),
|
|
|
|
folder.tcx().mk_bare_fn(bfn))
|
2015-06-13 13:15:03 -07:00
|
|
|
}
|
|
|
|
ty::TyFnPtr(ref f) => {
|
|
|
|
let bfn = f.fold_with(folder);
|
|
|
|
ty::TyFnPtr(folder.tcx().mk_bare_fn(bfn))
|
2015-11-18 09:38:57 +00:00
|
|
|
}
|
|
|
|
ty::TyRef(r, ref tm) => {
|
|
|
|
let r = r.fold_with(folder);
|
|
|
|
ty::TyRef(folder.tcx().mk_region(r), tm.fold_with(folder))
|
|
|
|
}
|
|
|
|
ty::TyStruct(did, ref substs) => {
|
|
|
|
let substs = substs.fold_with(folder);
|
|
|
|
ty::TyStruct(did, folder.tcx().mk_substs(substs))
|
|
|
|
}
|
|
|
|
ty::TyClosure(did, ref substs) => {
|
|
|
|
ty::TyClosure(did, substs.fold_with(folder))
|
|
|
|
}
|
|
|
|
ty::TyProjection(ref data) => ty::TyProjection(data.fold_with(folder)),
|
|
|
|
ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) |
|
|
|
|
ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) |
|
|
|
|
ty::TyParam(..) => self.sty.clone(),
|
|
|
|
};
|
|
|
|
folder.tcx().mk_ty(sty)
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|
|
|
folder.fold_ty(*self)
|
2015-11-18 09:38:57 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
match self.sty {
|
|
|
|
ty::TyBox(typ) => typ.visit_with(visitor),
|
|
|
|
ty::TyRawPtr(ref tm) => tm.visit_with(visitor),
|
|
|
|
ty::TyArray(typ, _sz) => typ.visit_with(visitor),
|
|
|
|
ty::TySlice(typ) => typ.visit_with(visitor),
|
|
|
|
ty::TyEnum(_tid, ref substs) => substs.visit_with(visitor),
|
|
|
|
ty::TyTrait(ref trait_ty) => trait_ty.visit_with(visitor),
|
|
|
|
ty::TyTuple(ref ts) => ts.visit_with(visitor),
|
2016-02-16 18:36:41 +02:00
|
|
|
ty::TyFnDef(_, substs, ref f) => {
|
|
|
|
substs.visit_with(visitor) || f.visit_with(visitor)
|
|
|
|
}
|
|
|
|
ty::TyFnPtr(ref f) => f.visit_with(visitor),
|
2015-11-18 09:38:57 +00:00
|
|
|
ty::TyRef(r, ref tm) => r.visit_with(visitor) || tm.visit_with(visitor),
|
|
|
|
ty::TyStruct(_did, ref substs) => substs.visit_with(visitor),
|
|
|
|
ty::TyClosure(_did, ref substs) => substs.visit_with(visitor),
|
|
|
|
ty::TyProjection(ref data) => data.visit_with(visitor),
|
|
|
|
ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) |
|
|
|
|
ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) |
|
|
|
|
ty::TyParam(..) => false,
|
|
|
|
}
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
|
|
|
visitor.visit_ty(self)
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
2016-01-06 02:01:28 +00:00
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::BareFnTy<'tcx> {
|
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
ty::BareFnTy { sig: self.sig.fold_with(folder),
|
|
|
|
abi: self.abi,
|
|
|
|
unsafety: self.unsafety }
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
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 {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.sig.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::ClosureTy<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
ty::ClosureTy {
|
|
|
|
sig: self.sig.fold_with(folder),
|
|
|
|
unsafety: self.unsafety,
|
|
|
|
abi: self.abi,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
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 {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.sig.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::TypeAndMut<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|
|
|
ty::TypeAndMut { ty: self.ty.fold_with(folder), mutbl: self.mutbl }
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|
|
|
folder.fold_mt(self)
|
2015-11-18 09:38:57 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.ty.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::FnOutput<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
match *self {
|
|
|
|
ty::FnConverging(ref ty) => ty::FnConverging(ty.fold_with(folder)),
|
|
|
|
ty::FnDiverging => ty::FnDiverging
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
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 {
|
2015-11-18 09:38:57 +00:00
|
|
|
match *self {
|
|
|
|
ty::FnConverging(ref ty) => ty.visit_with(visitor),
|
|
|
|
ty::FnDiverging => false,
|
|
|
|
}
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::FnSig<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
ty::FnSig { inputs: self.inputs.fold_with(folder),
|
|
|
|
output: self.output.fold_with(folder),
|
|
|
|
variadic: self.variadic }
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
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 {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.inputs.visit_with(visitor) || self.output.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::TraitRef<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
let substs = self.substs.fold_with(folder);
|
|
|
|
ty::TraitRef {
|
|
|
|
def_id: self.def_id,
|
|
|
|
substs: folder.tcx().mk_substs(substs),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
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 {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.substs.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
2016-02-26 10:51:10 -08:00
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::ImplHeader<'tcx> {
|
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|
|
|
ty::ImplHeader {
|
|
|
|
impl_def_id: self.impl_def_id,
|
|
|
|
self_ty: self.self_ty.fold_with(folder),
|
|
|
|
trait_ref: self.trait_ref.map(|t| t.fold_with(folder)),
|
2016-02-26 13:21:44 -08:00
|
|
|
predicates: self.predicates.iter().map(|p| p.fold_with(folder)).collect(),
|
2016-02-26 10:51:10 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
|
|
|
folder.fold_impl_header(self)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
|
|
|
self.self_ty.visit_with(visitor) ||
|
|
|
|
self.trait_ref.map(|r| r.visit_with(visitor)).unwrap_or(false) ||
|
|
|
|
self.predicates.iter().any(|p| p.visit_with(visitor))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-06 21:51:58 +03:00
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::Region {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> Self {
|
|
|
|
*self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
folder.fold_region(*self)
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
|
|
|
|
false
|
2015-11-18 09:38:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
|
|
|
visitor.visit_region(*self)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for subst::Substs<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2016-03-09 18:22:05 -05:00
|
|
|
subst::Substs { regions: self.regions.fold_with(folder),
|
2015-11-18 09:38:57 +00:00
|
|
|
types: self.types.fold_with(folder) }
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
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 {
|
2016-03-09 18:22:05 -05:00
|
|
|
self.types.visit_with(visitor) || self.regions.visit_with(visitor)
|
2015-11-18 09:38:57 +00:00
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::ClosureSubsts<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
let func_substs = self.func_substs.fold_with(folder);
|
|
|
|
ty::ClosureSubsts {
|
|
|
|
func_substs: folder.tcx().mk_substs(func_substs),
|
|
|
|
upvar_tys: self.upvar_tys.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.func_substs.visit_with(visitor) || self.upvar_tys.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::ItemSubsts<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::ItemSubsts {
|
|
|
|
substs: self.substs.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.substs.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
2015-09-14 14:55:56 +03:00
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::adjustment::AutoRef<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
match *self {
|
|
|
|
ty::adjustment::AutoPtr(r, m) => {
|
|
|
|
let r = r.fold_with(folder);
|
|
|
|
ty::adjustment::AutoPtr(folder.tcx().mk_region(r), m)
|
|
|
|
}
|
|
|
|
ty::adjustment::AutoUnsafe(m) => ty::adjustment::AutoUnsafe(m)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
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 {
|
2015-11-18 09:38:57 +00:00
|
|
|
match *self {
|
|
|
|
ty::adjustment::AutoPtr(r, _m) => r.visit_with(visitor),
|
|
|
|
ty::adjustment::AutoUnsafe(_m) => false,
|
|
|
|
}
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::BuiltinBounds {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
*self
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
false
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::ExistentialBounds<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
ty::ExistentialBounds {
|
|
|
|
region_bound: self.region_bound.fold_with(folder),
|
|
|
|
builtin_bounds: self.builtin_bounds,
|
|
|
|
projection_bounds: self.projection_bounds.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
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 {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.region_bound.visit_with(visitor) || self.projection_bounds.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::TypeParameterDef<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::TypeParameterDef {
|
|
|
|
name: self.name,
|
|
|
|
def_id: self.def_id,
|
|
|
|
space: self.space,
|
|
|
|
index: self.index,
|
|
|
|
default: self.default.fold_with(folder),
|
|
|
|
default_def_id: self.default_def_id,
|
|
|
|
object_lifetime_default: self.object_lifetime_default.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.default.visit_with(visitor) ||
|
|
|
|
self.object_lifetime_default.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::ObjectLifetimeDefault {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
match *self {
|
|
|
|
ty::ObjectLifetimeDefault::Ambiguous =>
|
|
|
|
ty::ObjectLifetimeDefault::Ambiguous,
|
|
|
|
|
|
|
|
ty::ObjectLifetimeDefault::BaseDefault =>
|
|
|
|
ty::ObjectLifetimeDefault::BaseDefault,
|
|
|
|
|
|
|
|
ty::ObjectLifetimeDefault::Specific(r) =>
|
|
|
|
ty::ObjectLifetimeDefault::Specific(r.fold_with(folder)),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
match *self {
|
|
|
|
ty::ObjectLifetimeDefault::Specific(r) => r.visit_with(visitor),
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::RegionParameterDef {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::RegionParameterDef {
|
|
|
|
name: self.name,
|
|
|
|
def_id: self.def_id,
|
|
|
|
space: self.space,
|
|
|
|
index: self.index,
|
|
|
|
bounds: self.bounds.fold_with(folder)
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.bounds.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::Generics<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::Generics {
|
|
|
|
types: self.types.fold_with(folder),
|
|
|
|
regions: self.regions.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.types.visit_with(visitor) || self.regions.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::GenericPredicates<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::GenericPredicates {
|
|
|
|
predicates: self.predicates.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.predicates.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
match *self {
|
|
|
|
ty::Predicate::Trait(ref a) =>
|
|
|
|
ty::Predicate::Trait(a.fold_with(folder)),
|
2016-05-01 09:59:28 +03:00
|
|
|
ty::Predicate::Rfc1592(ref a) =>
|
|
|
|
ty::Predicate::Rfc1592(a.fold_with(folder)),
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::Predicate::Equate(ref binder) =>
|
|
|
|
ty::Predicate::Equate(binder.fold_with(folder)),
|
|
|
|
ty::Predicate::RegionOutlives(ref binder) =>
|
|
|
|
ty::Predicate::RegionOutlives(binder.fold_with(folder)),
|
|
|
|
ty::Predicate::TypeOutlives(ref binder) =>
|
|
|
|
ty::Predicate::TypeOutlives(binder.fold_with(folder)),
|
|
|
|
ty::Predicate::Projection(ref binder) =>
|
|
|
|
ty::Predicate::Projection(binder.fold_with(folder)),
|
|
|
|
ty::Predicate::WellFormed(data) =>
|
|
|
|
ty::Predicate::WellFormed(data.fold_with(folder)),
|
2016-04-06 00:20:59 -07:00
|
|
|
ty::Predicate::ClosureKind(closure_def_id, kind) =>
|
|
|
|
ty::Predicate::ClosureKind(closure_def_id, kind),
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::Predicate::ObjectSafe(trait_def_id) =>
|
|
|
|
ty::Predicate::ObjectSafe(trait_def_id),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
match *self {
|
|
|
|
ty::Predicate::Trait(ref a) => a.visit_with(visitor),
|
2016-05-01 09:59:28 +03:00
|
|
|
ty::Predicate::Rfc1592(ref a) => a.visit_with(visitor),
|
2015-11-18 09:38:57 +00:00
|
|
|
ty::Predicate::Equate(ref binder) => binder.visit_with(visitor),
|
|
|
|
ty::Predicate::RegionOutlives(ref binder) => binder.visit_with(visitor),
|
|
|
|
ty::Predicate::TypeOutlives(ref binder) => binder.visit_with(visitor),
|
|
|
|
ty::Predicate::Projection(ref binder) => binder.visit_with(visitor),
|
|
|
|
ty::Predicate::WellFormed(data) => data.visit_with(visitor),
|
2016-04-06 00:20:59 -07:00
|
|
|
ty::Predicate::ClosureKind(_closure_def_id, _kind) => false,
|
2015-11-18 09:38:57 +00:00
|
|
|
ty::Predicate::ObjectSafe(_trait_def_id) => false,
|
|
|
|
}
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::ProjectionPredicate<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::ProjectionPredicate {
|
|
|
|
projection_ty: self.projection_ty.fold_with(folder),
|
|
|
|
ty: self.ty.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.projection_ty.visit_with(visitor) || self.ty.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::ProjectionTy<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::ProjectionTy {
|
|
|
|
trait_ref: self.trait_ref.fold_with(folder),
|
|
|
|
item_name: self.item_name,
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.trait_ref.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::InstantiatedPredicates<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::InstantiatedPredicates {
|
|
|
|
predicates: self.predicates.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.predicates.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::EquatePredicate<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::EquatePredicate(self.0.fold_with(folder),
|
|
|
|
self.1.fold_with(folder))
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.0.visit_with(visitor) || self.1.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::TraitPredicate<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::TraitPredicate {
|
|
|
|
trait_ref: self.trait_ref.fold_with(folder)
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.trait_ref.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx,T,U> TypeFoldable<'tcx> for ty::OutlivesPredicate<T,U>
|
|
|
|
where T : TypeFoldable<'tcx>,
|
|
|
|
U : TypeFoldable<'tcx>,
|
|
|
|
{
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::OutlivesPredicate(self.0.fold_with(folder),
|
|
|
|
self.1.fold_with(folder))
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.0.visit_with(visitor) || self.1.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::ClosureUpvar<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::ClosureUpvar {
|
|
|
|
def: self.def,
|
|
|
|
span: self.span,
|
|
|
|
ty: self.ty.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.ty.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, 'tcx> TypeFoldable<'tcx> for ty::ParameterEnvironment<'a, 'tcx> where 'tcx: 'a {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-09-06 21:51:58 +03:00
|
|
|
ty::ParameterEnvironment {
|
|
|
|
tcx: self.tcx,
|
|
|
|
free_substs: self.free_substs.fold_with(folder),
|
|
|
|
implicit_region_bound: self.implicit_region_bound.fold_with(folder),
|
|
|
|
caller_bounds: self.caller_bounds.fold_with(folder),
|
|
|
|
selection_cache: traits::SelectionCache::new(),
|
2015-10-18 19:15:57 +03:00
|
|
|
evaluation_cache: traits::EvaluationCache::new(),
|
2015-12-08 23:38:36 +01:00
|
|
|
free_id_outlive: self.free_id_outlive,
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|
|
|
|
}
|
2015-11-18 09:38:57 +00:00
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.free_substs.visit_with(visitor) ||
|
|
|
|
self.implicit_region_bound.visit_with(visitor) ||
|
|
|
|
self.caller_bounds.visit_with(visitor)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> TypeFoldable<'tcx> for ty::TypeScheme<'tcx> {
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
2015-11-18 09:38:57 +00:00
|
|
|
ty::TypeScheme {
|
|
|
|
generics: self.generics.fold_with(folder),
|
|
|
|
ty: self.ty.fold_with(folder),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 02:01:28 +00:00
|
|
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
2015-11-18 09:38:57 +00:00
|
|
|
self.generics.visit_with(visitor) || self.ty.visit_with(visitor)
|
|
|
|
}
|
2015-09-06 21:51:58 +03:00
|
|
|
}
|