]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_infer/infer/canonical/query_response.rs
introduce PredicateAtom
[rust.git] / src / librustc_infer / infer / canonical / query_response.rs
index 5cba581b9dffb4c2bdc10c07d111e1d532436334..8406eb9bc175bd7519e8f55d7e6762ebbfb4a6c3 100644 (file)
@@ -525,28 +525,27 @@ fn query_outlives_constraints_into_obligations<'a>(
         result_subst: &'a CanonicalVarValues<'tcx>,
     ) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
         unsubstituted_region_constraints.iter().map(move |constraint| {
-            let constraint = substitute_value(self.tcx, result_subst, constraint);
-            let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
+            let ty::OutlivesPredicate(k1, r2) =
+                substitute_value(self.tcx, result_subst, constraint).skip_binder();
 
-            Obligation::new(
-                cause.clone(),
-                param_env,
-                match k1.unpack() {
-                    GenericArgKind::Lifetime(r1) => ty::PredicateKind::RegionOutlives(
-                        ty::Binder::bind(ty::OutlivesPredicate(r1, r2)),
-                    )
-                    .to_predicate(self.tcx),
-                    GenericArgKind::Type(t1) => ty::PredicateKind::TypeOutlives(ty::Binder::bind(
-                        ty::OutlivesPredicate(t1, r2),
-                    ))
-                    .to_predicate(self.tcx),
-                    GenericArgKind::Const(..) => {
-                        // Consts cannot outlive one another, so we don't expect to
-                        // ecounter this branch.
-                        span_bug!(cause.span, "unexpected const outlives {:?}", constraint);
-                    }
-                },
-            )
+            let predicate = match k1.unpack() {
+                GenericArgKind::Lifetime(r1) => {
+                    ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r1, r2))
+                        .to_predicate(self.tcx)
+                }
+                GenericArgKind::Type(t1) => {
+                    ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(t1, r2))
+                        .to_predicate(self.tcx)
+                }
+                GenericArgKind::Const(..) => {
+                    // Consts cannot outlive one another, so we don't expect to
+                    // encounter this branch.
+                    span_bug!(cause.span, "unexpected const outlives {:?}", constraint);
+                }
+            }
+            .potentially_quantified(self.tcx, ty::PredicateKind::ForAll);
+
+            Obligation::new(cause.clone(), param_env, predicate)
         })
     }
 
@@ -666,10 +665,8 @@ fn push_outlives(&mut self, sup: ty::Region<'tcx>, sub: ty::Region<'tcx>) {
         self.obligations.push(Obligation {
             cause: self.cause.clone(),
             param_env: self.param_env,
-            predicate: ty::PredicateKind::RegionOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
-                sup, sub,
-            )))
-            .to_predicate(self.infcx.tcx),
+            predicate: ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(sup, sub))
+                .to_predicate(self.infcx.tcx),
             recursion_depth: 0,
         });
     }