1
Fork 0

Introduce PredicateKind::Clause

This commit is contained in:
Santiago Pastorino 2022-11-24 18:14:58 -03:00
parent 42cc8e8f4e
commit 974e2837bb
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
75 changed files with 568 additions and 407 deletions

View file

@ -419,7 +419,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ensure_sufficient_stack(|| {
let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() {
ty::PredicateKind::Trait(t) => {
ty::PredicateKind::Clause(ty::Clause::Trait(t)) => {
let t = bound_predicate.rebind(t);
debug_assert!(!t.has_escaping_bound_vars());
let obligation = obligation.with(self.tcx(), t);
@ -546,7 +546,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::PredicateKind::TypeOutlives(pred) => {
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(pred)) => {
// A global type with no late-bound regions can only
// contain the "'static" lifetime (any other lifetime
// would either be late-bound or local), so it is guaranteed
@ -558,7 +558,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::PredicateKind::RegionOutlives(..) => {
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..)) => {
// We do not consider region relationships when evaluating trait matches.
Ok(EvaluatedToOkModuloRegions)
}
@ -571,7 +571,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::PredicateKind::Projection(data) => {
ty::PredicateKind::Clause(ty::Clause::Projection(data)) => {
let data = bound_predicate.rebind(data);
let project_obligation = obligation.with(self.tcx(), data);
match project::poly_project_and_unify_type(self, &project_obligation) {
@ -931,7 +931,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
let result = match predicate.kind().skip_binder() {
ty::PredicateKind::Trait(ref data) => self.tcx().trait_is_coinductive(data.def_id()),
ty::PredicateKind::Clause(ty::Clause::Trait(ref data)) => {
self.tcx().trait_is_coinductive(data.def_id())
}
ty::PredicateKind::WellFormed(_) => true,
_ => false,
};
@ -1377,7 +1379,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.enumerate()
.filter_map(|(idx, bound)| {
let bound_predicate = bound.kind();
if let ty::PredicateKind::Trait(pred) = bound_predicate.skip_binder() {
if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) =
bound_predicate.skip_binder()
{
let bound = bound_predicate.rebind(pred.trait_ref);
if self.infcx.probe(|_| {
match self.match_normalize_trait_ref(