about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-06-17 22:50:28 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-27 21:06:35 +0200
commit653f56af53c01c38f34f0926dd13ee391a290fa0 (patch)
treecbfc6bbf15c3f73966a37447edc71bb9833f0234
parentc1d244ffd881f59f1c8e5b7bdce38a1a80a0f7d6 (diff)
downloadrust-653f56af53c01c38f34f0926dd13ee391a290fa0.tar.gz
rust-653f56af53c01c38f34f0926dd13ee391a290fa0.zip
wf
-rw-r--r--src/librustc_trait_selection/traits/wf.rs36
-rw-r--r--src/librustc_typeck/check/wfcheck.rs2
2 files changed, 20 insertions, 18 deletions
diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs
index 4eb1d1856fb..333f90d78a7 100644
--- a/src/librustc_trait_selection/traits/wf.rs
+++ b/src/librustc_trait_selection/traits/wf.rs
@@ -88,33 +88,35 @@ pub fn predicate_obligations<'a, 'tcx>(
     infcx: &InferCtxt<'a, 'tcx>,
     param_env: ty::ParamEnv<'tcx>,
     body_id: hir::HirId,
-    predicate: ty::Predicate<'tcx>,
+    predicate: &'tcx ty::PredicateKint<'tcx>,
     span: Span,
 ) -> Vec<traits::PredicateObligation<'tcx>> {
     let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![], item: None };
 
-    // (*) ok to skip binders, because wf code is prepared for it
-    match predicate.kind() {
-        ty::PredicateKind::Trait(t, _) => {
-            wf.compute_trait_ref(&t.skip_binder().trait_ref, Elaborate::None); // (*)
+    match predicate {
+        ty::PredicateKint::ForAll(binder) => {
+            // It's ok to skip the binder here because wf code is prepared for it
+            return predicate_obligations(infcx, param_env, body_id, *binder.skip_binder(), span);
         }
-        ty::PredicateKind::RegionOutlives(..) => {}
-        ty::PredicateKind::TypeOutlives(t) => {
-            wf.compute(t.skip_binder().0.into());
+        ty::PredicateKint::Trait(t, _) => {
+            wf.compute_trait_ref(&t.trait_ref, Elaborate::None);
         }
-        ty::PredicateKind::Projection(t) => {
-            let t = t.skip_binder(); // (*)
+        ty::PredicateKint::RegionOutlives(..) => {}
+        &ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
+            wf.compute(ty.into());
+        }
+        ty::PredicateKint::Projection(t) => {
             wf.compute_projection(t.projection_ty);
             wf.compute(t.ty.into());
         }
-        &ty::PredicateKind::WellFormed(arg) => {
+        &ty::PredicateKint::WellFormed(arg) => {
             wf.compute(arg);
         }
-        ty::PredicateKind::ObjectSafe(_) => {}
-        ty::PredicateKind::ClosureKind(..) => {}
-        ty::PredicateKind::Subtype(data) => {
-            wf.compute(data.skip_binder().a.into()); // (*)
-            wf.compute(data.skip_binder().b.into()); // (*)
+        ty::PredicateKint::ObjectSafe(_) => {}
+        ty::PredicateKint::ClosureKind(..) => {}
+        &ty::PredicateKint::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ }) => {
+            wf.compute(a.into());
+            wf.compute(b.into());
         }
         &ty::PredicateKind::ConstEvaluatable(def, substs) => {
             let obligations = wf.nominal_obligations(def.did, substs);
@@ -124,7 +126,7 @@ pub fn predicate_obligations<'a, 'tcx>(
                 wf.compute(arg);
             }
         }
-        &ty::PredicateKind::ConstEquate(c1, c2) => {
+        &ty::PredicateKint::ConstEquate(c1, c2) => {
             wf.compute(c1.into());
             wf.compute(c2.into());
         }
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index dabae6cbc41..aa40d7de6e0 100644
--- a/src/librustc_typeck/check/wfcheck.rs
+++ b/src/librustc_typeck/check/wfcheck.rs
@@ -829,7 +829,7 @@ fn check_where_clauses<'tcx, 'fcx>(
     assert_eq!(predicates.predicates.len(), predicates.spans.len());
     let wf_obligations =
         predicates.predicates.iter().zip(predicates.spans.iter()).flat_map(|(&p, &sp)| {
-            traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, sp)
+            traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p.kint(tcx), sp)
         });
 
     for obligation in wf_obligations.chain(default_obligations) {