about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorscalexm <alexandre@scalexm.fr>2018-10-25 16:01:10 +0200
committerscalexm <alexandre@scalexm.fr>2018-11-03 11:41:55 +0100
commitc5ed72fbfe8aae9ebc4c73dce3f1ef11388913d9 (patch)
tree2a72923317663f5811d4bb21d9f742d0e82b7579 /src
parent07519975308af252a2fea6b89c3ad59374e29f39 (diff)
downloadrust-c5ed72fbfe8aae9ebc4c73dce3f1ef11388913d9.tar.gz
rust-c5ed72fbfe8aae9ebc4c73dce3f1ef11388913d9.zip
Substitute binders directly
Diffstat (limited to 'src')
-rw-r--r--src/librustc/infer/canonical/query_response.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/librustc/infer/canonical/query_response.rs b/src/librustc/infer/canonical/query_response.rs
index 5154abd6ce5..f4607f7a909 100644
--- a/src/librustc/infer/canonical/query_response.rs
+++ b/src/librustc/infer/canonical/query_response.rs
@@ -308,12 +308,14 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
         // ...also include the other query region constraints from the query.
         output_query_region_constraints.extend(
             query_response.value.region_constraints.iter().filter_map(|r_c| {
-                let ty::OutlivesPredicate(k1, r2) = r_c.skip_binder(); // reconstructed below
-                let k1 = substitute_value(self.tcx, &result_subst, &ty::Binder::bind(*k1));
-                let r2 = substitute_value(self.tcx, &result_subst, &ty::Binder::bind(*r2));
-                if k1 != r2.map_bound(|bound| bound.into()) {
-                    let predicate = ty::OutlivesPredicate(*k1.skip_binder(), *r2.skip_binder());
-                    Some(ty::Binder::bind(predicate))
+                let r_c = substitute_value(self.tcx, &result_subst, r_c);
+
+                // Screen out `'a: 'a` cases -- we skip the binder here but
+                // only care the inner values to one another, so they are still at
+                // consistent binding levels.
+                let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder();
+                if k1 != r2.into() {
+                    Some(r_c)
                 } else {
                     None
                 }
@@ -530,22 +532,21 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
             unsubstituted_region_constraints
                 .iter()
                 .map(move |constraint| {
-                    let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
-                    let k1 = substitute_value(self.tcx, result_subst, &ty::Binder::bind(*k1));
-                    let r2 = substitute_value(self.tcx, result_subst, &ty::Binder::bind(*r2));
+                    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.skip_binder().unpack() {
+                        match k1.unpack() {
                             UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives(
                                 ty::Binder::bind(
-                                    ty::OutlivesPredicate(r1, r2.skip_binder())
+                                    ty::OutlivesPredicate(r1, r2)
                                 )
                             ),
                             UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives(
                                 ty::Binder::bind(
-                                    ty::OutlivesPredicate(t1, r2.skip_binder())
+                                    ty::OutlivesPredicate(t1, r2)
                                 )
                             ),
                         }