}
}
-impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> {
- type Lifted = ty::Binder<T::Lifted>;
+impl<'a, 'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<'a, T>
+where
+ <T as Lift<'tcx>>::Lifted: TypeFoldable<'tcx>,
+{
+ type Lifted = ty::Binder<'tcx, T::Lifted>;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
- self.map_bound(|v| tcx.lift(v)).transpose()
+ let bound_vars = tcx.lift(self.bound_vars());
+ tcx.lift(self.skip_binder())
+ .zip(bound_vars)
+ .map(|(value, vars)| ty::Binder::bind_with_vars(value, vars))
}
}
}
}
-impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
+impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<'tcx, T> {
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
self.map_bound(|ty| ty.fold_with(folder))
}
}
}
-impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>> {
+impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>> {
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_poly_existential_predicates(v))
}
match self {
ty::ConstKind::Infer(ic) => ty::ConstKind::Infer(ic.fold_with(folder)),
ty::ConstKind::Param(p) => ty::ConstKind::Param(p.fold_with(folder)),
- ty::ConstKind::Unevaluated(did, substs, promoted) => {
- ty::ConstKind::Unevaluated(did, substs.fold_with(folder), promoted)
+ ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }) => {
+ ty::ConstKind::Unevaluated(ty::Unevaluated {
+ def,
+ substs: substs.fold_with(folder),
+ promoted,
+ })
}
ty::ConstKind::Value(_)
| ty::ConstKind::Bound(..)
match *self {
ty::ConstKind::Infer(ic) => ic.visit_with(visitor),
ty::ConstKind::Param(p) => p.visit_with(visitor),
- ty::ConstKind::Unevaluated(_, substs, _) => substs.visit_with(visitor),
+ ty::ConstKind::Unevaluated(ct) => ct.substs.visit_with(visitor),
ty::ConstKind::Value(_)
| ty::ConstKind::Bound(..)
| ty::ConstKind::Placeholder(_)