ty::PredicateKind::RegionOutlives(ref pair) => pair.fmt(f),
ty::PredicateKind::TypeOutlives(ref pair) => pair.fmt(f),
ty::PredicateKind::Projection(ref pair) => pair.fmt(f),
- ty::PredicateKind::WellFormed(ty) => write!(f, "WellFormed({:?})", ty),
+ ty::PredicateKind::WellFormed(data) => write!(f, "WellFormed({:?})", data),
ty::PredicateKind::ObjectSafe(trait_def_id) => {
write!(f, "ObjectSafe({:?})", trait_def_id)
}
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> {
type Lifted = ty::Binder<T::Lifted>;
fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
- tcx.lift(self.skip_binder()).map(ty::Binder::bind)
+ tcx.lift(self.as_ref().skip_binder()).map(ty::Binder::bind)
}
}
impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> {
type Lifted = ty::ParamEnv<'tcx>;
fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
- tcx.lift(&self.caller_bounds).map(|caller_bounds| ty::ParamEnv {
- reveal: self.reveal,
- caller_bounds,
- def_id: self.def_id,
- })
+ tcx.lift(&self.caller_bounds())
+ .map(|caller_bounds| ty::ParamEnv::new(caller_bounds, self.reveal(), self.def_id))
}
}
VariadicMismatch(x) => VariadicMismatch(x),
CyclicTy(t) => return tcx.lift(&t).map(|t| CyclicTy(t)),
ProjectionMismatched(x) => ProjectionMismatched(x),
- ProjectionBoundsLength(x) => ProjectionBoundsLength(x),
Sorts(ref x) => return tcx.lift(x).map(Sorts),
ExistentialMismatch(ref x) => return tcx.lift(x).map(ExistentialMismatch),
ConstMismatch(ref x) => return tcx.lift(x).map(ConstMismatch),
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
- self.skip_binder().visit_with(visitor)
+ self.as_ref().skip_binder().visit_with(visitor)
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
| ty::Int(_)
| ty::Uint(_)
| ty::Float(_)
- | ty::Error
+ | ty::Error(_)
| ty::Infer(_)
| ty::Param(..)
| ty::Bound(..)
| ty::Int(_)
| ty::Uint(_)
| ty::Float(_)
- | ty::Error
+ | ty::Error(_)
| ty::Infer(_)
| ty::Bound(..)
| ty::Placeholder(..)
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
- folder.tcx().mk_predicate(ty::PredicateKind::super_fold_with(self.kind, folder))
+ let new = ty::PredicateKind::super_fold_with(&self.inner.kind, folder);
+ if new != self.inner.kind { folder.tcx().mk_predicate(new) } else { *self }
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
- ty::PredicateKind::super_visit_with(self.kind, visitor)
+ ty::PredicateKind::super_visit_with(&self.inner.kind, visitor)
+ }
+
+ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
+ visitor.visit_predicate(*self)
+ }
+
+ fn has_vars_bound_at_or_above(&self, binder: ty::DebruijnIndex) -> bool {
+ self.inner.outer_exclusive_binder > binder
+ }
+
+ fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
+ self.inner.flags.intersects(flags)
+ }
+}
+
+pub(super) trait PredicateVisitor<'tcx>: TypeVisitor<'tcx> {
+ fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool;
+}
+
+impl<T: TypeVisitor<'tcx>> PredicateVisitor<'tcx> for T {
+ default fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> bool {
+ predicate.super_visit_with(self)
}
}
ty::ConstKind::Value(_)
| ty::ConstKind::Bound(..)
| ty::ConstKind::Placeholder(..)
- | ty::ConstKind::Error => *self,
+ | ty::ConstKind::Error(_) => *self,
}
}
ty::ConstKind::Value(_)
| ty::ConstKind::Bound(..)
| ty::ConstKind::Placeholder(_)
- | ty::ConstKind::Error => false,
+ | ty::ConstKind::Error(_) => false,
}
}
}