about summary refs log tree commit diff
path: root/compiler/rustc_traits/src
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2022-11-24 18:14:58 -0300
committerSantiago Pastorino <spastorino@gmail.com>2022-11-25 00:04:54 -0300
commit974e2837bb643a1213caeea4025f2f5681bd5f3e (patch)
treeef25aad9b89c8cb4f8f618f153c04f3dd2aa8b87 /compiler/rustc_traits/src
parent42cc8e8f4e5fe3864a9aca4f342ee2aff2ba696a (diff)
downloadrust-974e2837bb643a1213caeea4025f2f5681bd5f3e.tar.gz
rust-974e2837bb643a1213caeea4025f2f5681bd5f3e.zip
Introduce PredicateKind::Clause
Diffstat (limited to 'compiler/rustc_traits/src')
-rw-r--r--compiler/rustc_traits/src/chalk/lowering.rs88
-rw-r--r--compiler/rustc_traits/src/implied_outlives_bounds.rs17
-rw-r--r--compiler/rustc_traits/src/normalize_erasing_regions.rs7
3 files changed, 63 insertions, 49 deletions
diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs
index 9931a7f32ef..c4ab86e9e9b 100644
--- a/compiler/rustc_traits/src/chalk/lowering.rs
+++ b/compiler/rustc_traits/src/chalk/lowering.rs
@@ -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(..)
diff --git a/compiler/rustc_traits/src/implied_outlives_bounds.rs b/compiler/rustc_traits/src/implied_outlives_bounds.rs
index 3ab353c9638..010233d7718 100644
--- a/compiler/rustc_traits/src/implied_outlives_bounds.rs
+++ b/compiler/rustc_traits/src/implied_outlives_bounds.rs
@@ -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)),
                 },
             }
         }));
diff --git a/compiler/rustc_traits/src/normalize_erasing_regions.rs b/compiler/rustc_traits/src/normalize_erasing_regions.rs
index 5200908527a..bd22d113b40 100644
--- a/compiler/rustc_traits/src/normalize_erasing_regions.rs
+++ b/compiler/rustc_traits/src/normalize_erasing_regions.rs
@@ -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(..)