|
|
|
|
@@ -234,10 +234,10 @@ impl<'tcx> PolyExistentialPredicate<'tcx> {
|
|
|
|
|
pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::Clause<'tcx> {
|
|
|
|
|
match self.skip_binder() {
|
|
|
|
|
ExistentialPredicate::Trait(tr) => {
|
|
|
|
|
self.rebind(tr).with_self_ty(tcx, self_ty).to_predicate(tcx)
|
|
|
|
|
self.rebind(tr).with_self_ty(tcx, self_ty).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
ExistentialPredicate::Projection(p) => {
|
|
|
|
|
self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx)
|
|
|
|
|
self.rebind(p.with_self_ty(tcx, self_ty)).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
ExistentialPredicate::AutoTrait(did) => {
|
|
|
|
|
let generics = tcx.generics_of(did);
|
|
|
|
|
@@ -249,7 +249,7 @@ impl<'tcx> PolyExistentialPredicate<'tcx> {
|
|
|
|
|
let err_args = ty::GenericArgs::extend_with_error(tcx, did, &[self_ty.into()]);
|
|
|
|
|
ty::TraitRef::new(tcx, did, err_args)
|
|
|
|
|
};
|
|
|
|
|
self.rebind(trait_ref).to_predicate(tcx)
|
|
|
|
|
self.rebind(trait_ref).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -544,106 +544,106 @@ impl<'tcx> ToPolyTraitRef<'tcx> for PolyTraitPredicate<'tcx> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait ToPredicate<'tcx, P = Predicate<'tcx>> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> P;
|
|
|
|
|
pub trait Upcast<'tcx, P = Predicate<'tcx>> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> P;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx, T> ToPredicate<'tcx, T> for T {
|
|
|
|
|
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T {
|
|
|
|
|
impl<'tcx, T> Upcast<'tcx, T> for T {
|
|
|
|
|
fn upcast(self, _tcx: TyCtxt<'tcx>) -> T {
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for PredicateKind<'tcx> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for PredicateKind<'tcx> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
ty::Binder::dummy(self).to_predicate(tcx)
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
ty::Binder::dummy(self).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, PredicateKind<'tcx>> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for Binder<'tcx, PredicateKind<'tcx>> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
tcx.mk_predicate(self)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for ClauseKind<'tcx> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for ClauseKind<'tcx> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
tcx.mk_predicate(ty::Binder::dummy(ty::PredicateKind::Clause(self)))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, ClauseKind<'tcx>> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for Binder<'tcx, ClauseKind<'tcx>> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
tcx.mk_predicate(self.map_bound(ty::PredicateKind::Clause))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for Clause<'tcx> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for Clause<'tcx> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
fn upcast(self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
self.as_predicate()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for ClauseKind<'tcx> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx, Clause<'tcx>> for ClauseKind<'tcx> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
tcx.mk_predicate(Binder::dummy(ty::PredicateKind::Clause(self))).expect_clause()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for Binder<'tcx, ClauseKind<'tcx>> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx, Clause<'tcx>> for Binder<'tcx, ClauseKind<'tcx>> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
tcx.mk_predicate(self.map_bound(|clause| ty::PredicateKind::Clause(clause))).expect_clause()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for TraitRef<'tcx> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for TraitRef<'tcx> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
ty::Binder::dummy(self).to_predicate(tcx)
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
ty::Binder::dummy(self).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, TraitPredicate<'tcx>> for TraitRef<'tcx> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx, TraitPredicate<'tcx>> for TraitRef<'tcx> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> TraitPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, _tcx: TyCtxt<'tcx>) -> TraitPredicate<'tcx> {
|
|
|
|
|
TraitPredicate { trait_ref: self, polarity: PredicatePolarity::Positive }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for TraitRef<'tcx> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx, Clause<'tcx>> for TraitRef<'tcx> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.to_predicate(tcx);
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.upcast(tcx);
|
|
|
|
|
p.expect_clause()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, TraitRef<'tcx>> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for Binder<'tcx, TraitRef<'tcx>> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
let pred: PolyTraitPredicate<'tcx> = self.to_predicate(tcx);
|
|
|
|
|
pred.to_predicate(tcx)
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
let pred: PolyTraitPredicate<'tcx> = self.upcast(tcx);
|
|
|
|
|
pred.upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for Binder<'tcx, TraitRef<'tcx>> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx, Clause<'tcx>> for Binder<'tcx, TraitRef<'tcx>> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let pred: PolyTraitPredicate<'tcx> = self.to_predicate(tcx);
|
|
|
|
|
pred.to_predicate(tcx)
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let pred: PolyTraitPredicate<'tcx> = self.upcast(tcx);
|
|
|
|
|
pred.upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for Binder<'tcx, TraitRef<'tcx>> {
|
|
|
|
|
impl<'tcx> Upcast<'tcx, PolyTraitPredicate<'tcx>> for Binder<'tcx, TraitRef<'tcx>> {
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn to_predicate(self, _: TyCtxt<'tcx>) -> PolyTraitPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, _: TyCtxt<'tcx>) -> PolyTraitPredicate<'tcx> {
|
|
|
|
|
self.map_bound(|trait_ref| TraitPredicate {
|
|
|
|
|
trait_ref,
|
|
|
|
|
polarity: ty::PredicatePolarity::Positive,
|
|
|
|
|
@@ -651,73 +651,73 @@ impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for Binder<'tcx, TraitRef
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for TraitPredicate<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
PredicateKind::Clause(ClauseKind::Trait(self)).to_predicate(tcx)
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for TraitPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
PredicateKind::Clause(ClauseKind::Trait(self)).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for PolyTraitPredicate<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Trait(p))).to_predicate(tcx)
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for PolyTraitPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Trait(p))).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for TraitPredicate<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.to_predicate(tcx);
|
|
|
|
|
impl<'tcx> Upcast<'tcx, Clause<'tcx>> for TraitPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.upcast(tcx);
|
|
|
|
|
p.expect_clause()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyTraitPredicate<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.to_predicate(tcx);
|
|
|
|
|
impl<'tcx> Upcast<'tcx, Clause<'tcx>> for PolyTraitPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.upcast(tcx);
|
|
|
|
|
p.expect_clause()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::RegionOutlives(p))).to_predicate(tcx)
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::RegionOutlives(p))).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::TypeOutlives(self))).to_predicate(tcx)
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::TypeOutlives(self))).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for ProjectionPredicate<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::Projection(self))).to_predicate(tcx)
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for ProjectionPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::Projection(self))).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Projection(p))).to_predicate(tcx)
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for PolyProjectionPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Projection(p))).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for ProjectionPredicate<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.to_predicate(tcx);
|
|
|
|
|
impl<'tcx> Upcast<'tcx, Clause<'tcx>> for ProjectionPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.upcast(tcx);
|
|
|
|
|
p.expect_clause()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.to_predicate(tcx);
|
|
|
|
|
impl<'tcx> Upcast<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
|
|
|
|
|
let p: Predicate<'tcx> = self.upcast(tcx);
|
|
|
|
|
p.expect_clause()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> ToPredicate<'tcx> for NormalizesTo<'tcx> {
|
|
|
|
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
PredicateKind::NormalizesTo(self).to_predicate(tcx)
|
|
|
|
|
impl<'tcx> Upcast<'tcx> for NormalizesTo<'tcx> {
|
|
|
|
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
|
|
|
PredicateKind::NormalizesTo(self).upcast(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|