about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-06-24 17:54:13 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-07-27 21:06:36 +0200
commitd030752f63b9d52bb5fa8733080e674697640866 (patch)
tree2700be6fb4bcb5d315143e1a903a7180e32cc950
parent3ba61922d2500e156df7f76ffeccf022cdeb0f9a (diff)
downloadrust-d030752f63b9d52bb5fa8733080e674697640866.tar.gz
rust-d030752f63b9d52bb5fa8733080e674697640866.zip
refactor query_outlives_constraints_into_obligations
-rw-r--r--src/librustc_infer/infer/canonical/query_response.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/librustc_infer/infer/canonical/query_response.rs b/src/librustc_infer/infer/canonical/query_response.rs
index 3541bf3b809..1a54fa0657c 100644
--- a/src/librustc_infer/infer/canonical/query_response.rs
+++ b/src/librustc_infer/infer/canonical/query_response.rs
@@ -525,12 +525,10 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
         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) =
+                *substitute_value(self.tcx, result_subst, constraint).skip_binder();
 
-            let to_predicate = |ty::OutlivesPredicate(k1, r2): ty::OutlivesPredicate<
-                GenericArg<'tcx>,
-                ty::Region<'tcx>,
-            >| match k1.unpack() {
+            let predicate = match k1.unpack() {
                 GenericArgKind::Lifetime(r1) => {
                     ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
                         .to_predicate(self.tcx)
@@ -541,16 +539,11 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
                 }
                 GenericArgKind::Const(..) => {
                     // Consts cannot outlive one another, so we don't expect to
-                    // ecounter this branch.
+                    // encounter this branch.
                     span_bug!(cause.span, "unexpected const outlives {:?}", constraint);
                 }
-            };
-
-            let predicate = if let Some(constraint) = constraint.no_bound_vars() {
-                to_predicate(constraint)
-            } else {
-                ty::PredicateKind::ForAll(constraint.map_bound(to_predicate)).to_predicate(self.tcx)
-            };
+            }
+            .potentially_quantified(self.tcx, ty::PredicateKind::ForAll);
 
             Obligation::new(cause.clone(), param_env, predicate)
         })