about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-06-17 10:46:52 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-27 21:06:35 +0200
commitfb36c8bc80b4d8f071317adbb05337c9a0a2dbae (patch)
tree97b98e0d1bb89c6f48d8b13d0b395dcf4aa0a4e6
parentcd30894c2f7113bf79c7f66d30a774f11b315d3f (diff)
downloadrust-fb36c8bc80b4d8f071317adbb05337c9a0a2dbae.tar.gz
rust-fb36c8bc80b4d8f071317adbb05337c9a0a2dbae.zip
query_outlives_constraints_into_obligations
-rw-r--r--src/librustc_infer/infer/canonical/query_response.rs44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/librustc_infer/infer/canonical/query_response.rs b/src/librustc_infer/infer/canonical/query_response.rs
index 5cba581b9df..89add21a7cd 100644
--- a/src/librustc_infer/infer/canonical/query_response.rs
+++ b/src/librustc_infer/infer/canonical/query_response.rs
@@ -526,27 +526,31 @@ impl<'cx, 'tcx> InferCtxt<'cx, '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
 
-            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 to_predicate = |ty::OutlivesPredicate(k1, r2): ty::OutlivesPredicate<
+                GenericArg<'tcx>,
+                ty::Region<'tcx>,
+            >| match k1.unpack() {
+                GenericArgKind::Lifetime(r1) => self.tcx.intern_predicate_kint(
+                    ty::PredicateKint::RegionOutlives(ty::OutlivesPredicate(r1, r2)),
+                ),
+                GenericArgKind::Type(t1) => self.tcx.intern_predicate_kint(
+                    ty::PredicateKint::TypeOutlives(ty::OutlivesPredicate(t1, r2)),
+                ),
+                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 = if let Some(constraint) = constraint.no_bound_vars() {
+                to_predicate(constraint).to_predicate(self.tcx)
+            } else {
+                ty::PredicateKint::ForAll(constraint.map_bound(to_predicate)).to_predicate(self.tcx)
+            };
+
+            Obligation::new(cause.clone(), param_env, predicate)
         })
     }