Introduce PredicateKind::Clause
This commit is contained in:
parent
42cc8e8f4e
commit
974e2837bb
75 changed files with 568 additions and 407 deletions
|
@ -89,24 +89,32 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
|
|||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
||||
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner)))
|
||||
}
|
||||
ty::PredicateKind::Trait(predicate) => chalk_ir::DomainGoal::FromEnv(
|
||||
chalk_ir::FromEnv::Trait(predicate.trait_ref.lower_into(interner)),
|
||||
),
|
||||
ty::PredicateKind::RegionOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
b: predicate.1.lower_into(interner),
|
||||
}),
|
||||
),
|
||||
ty::PredicateKind::TypeOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
lifetime: predicate.1.lower_into(interner),
|
||||
}),
|
||||
),
|
||||
ty::PredicateKind::Projection(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
|
||||
),
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
|
||||
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Trait(
|
||||
predicate.trait_ref.lower_into(interner),
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(predicate)) => {
|
||||
chalk_ir::DomainGoal::Holds(chalk_ir::WhereClause::LifetimeOutlives(
|
||||
chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
b: predicate.1.lower_into(interner),
|
||||
},
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(predicate)) => {
|
||||
chalk_ir::DomainGoal::Holds(chalk_ir::WhereClause::TypeOutlives(
|
||||
chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
lifetime: predicate.1.lower_into(interner),
|
||||
},
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => {
|
||||
chalk_ir::DomainGoal::Holds(chalk_ir::WhereClause::AliasEq(
|
||||
predicate.lower_into(interner),
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::WellFormed(arg) => match arg.unpack() {
|
||||
ty::GenericArgKind::Type(ty) => chalk_ir::DomainGoal::WellFormed(
|
||||
chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
|
||||
|
@ -149,12 +157,12 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
|||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
|
||||
let value = match predicate {
|
||||
ty::PredicateKind::Trait(predicate) => {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)),
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(predicate)) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
|
@ -162,7 +170,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
|||
}),
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::TypeOutlives(predicate) => {
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(predicate)) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
|
@ -170,7 +178,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
|||
}),
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::Projection(predicate) => {
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
|
||||
))
|
||||
|
@ -605,22 +613,22 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
|
|||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
let value = match predicate {
|
||||
ty::PredicateKind::Trait(predicate) => {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
|
||||
Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)))
|
||||
}
|
||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(predicate)) => {
|
||||
Some(chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
b: predicate.1.lower_into(interner),
|
||||
}))
|
||||
}
|
||||
ty::PredicateKind::TypeOutlives(predicate) => {
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(predicate)) => {
|
||||
Some(chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
lifetime: predicate.1.lower_into(interner),
|
||||
}))
|
||||
}
|
||||
ty::PredicateKind::Projection(predicate) => {
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => {
|
||||
Some(chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)))
|
||||
}
|
||||
ty::PredicateKind::WellFormed(_ty) => None,
|
||||
|
@ -741,20 +749,24 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
|
|||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
match predicate {
|
||||
ty::PredicateKind::Trait(predicate) => Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::TraitBound(
|
||||
predicate.trait_ref.lower_into(interner),
|
||||
),
|
||||
)),
|
||||
ty::PredicateKind::Projection(predicate) => Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)),
|
||||
)),
|
||||
ty::PredicateKind::TypeOutlives(_predicate) => None,
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
|
||||
Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::TraitBound(
|
||||
predicate.trait_ref.lower_into(interner),
|
||||
),
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => {
|
||||
Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)),
|
||||
))
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_predicate)) => None,
|
||||
ty::PredicateKind::WellFormed(_ty) => None,
|
||||
|
||||
ty::PredicateKind::RegionOutlives(..)
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
|
|
|
@ -86,10 +86,10 @@ fn compute_implied_outlives_bounds<'tcx>(
|
|||
match obligation.predicate.kind().no_bound_vars() {
|
||||
None => None,
|
||||
Some(pred) => match pred {
|
||||
ty::PredicateKind::Trait(..)
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::Coerce(..)
|
||||
| ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
|
@ -101,13 +101,14 @@ fn compute_implied_outlives_bounds<'tcx>(
|
|||
None
|
||||
}
|
||||
|
||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
|
||||
Some(ty::OutlivesPredicate(r_a.into(), r_b))
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
|
||||
ty::OutlivesPredicate(r_a, r_b),
|
||||
)) => Some(ty::OutlivesPredicate(r_a.into(), r_b)),
|
||||
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, r_b)) => {
|
||||
Some(ty::OutlivesPredicate(ty_a.into(), r_b))
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
|
||||
ty_a,
|
||||
r_b,
|
||||
))) => Some(ty::OutlivesPredicate(ty_a.into(), r_b)),
|
||||
},
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -56,9 +56,10 @@ fn try_normalize_after_erasing_regions<'tcx, T: TypeFoldable<'tcx> + PartialEq +
|
|||
|
||||
fn not_outlives_predicate<'tcx>(p: ty::Predicate<'tcx>) -> bool {
|
||||
match p.kind().skip_binder() {
|
||||
ty::PredicateKind::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
|
||||
ty::PredicateKind::Trait(..)
|
||||
| ty::PredicateKind::Projection(..)
|
||||
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
|
||||
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) => false,
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(..))
|
||||
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
|
||||
| ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue