Skip to content

Commit 2b205dc

Browse files
committed
Substitute binders directly
1 parent 2bf01aa commit 2b205dc

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/librustc/infer/canonical/query_response.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,14 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
308308
// ...also include the other query region constraints from the query.
309309
output_query_region_constraints.extend(
310310
query_response.value.region_constraints.iter().filter_map(|r_c| {
311-
let ty::OutlivesPredicate(k1, r2) = r_c.skip_binder(); // reconstructed below
312-
let k1 = substitute_value(self.tcx, &result_subst, &ty::Binder::bind(*k1));
313-
let r2 = substitute_value(self.tcx, &result_subst, &ty::Binder::bind(*r2));
314-
if k1 != r2.map_bound(|bound| bound.into()) {
315-
let predicate = ty::OutlivesPredicate(*k1.skip_binder(), *r2.skip_binder());
316-
Some(ty::Binder::bind(predicate))
311+
let r_c = substitute_value(self.tcx, &result_subst, r_c);
312+
313+
// Screen out `'a: 'a` cases -- we skip the binder here but
314+
// only care the inner values to one another, so they are still at
315+
// consistent binding levels.
316+
let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder();
317+
if k1 != r2.into() {
318+
Some(r_c)
317319
} else {
318320
None
319321
}
@@ -504,22 +506,21 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
504506
unsubstituted_region_constraints
505507
.iter()
506508
.map(move |constraint| {
507-
let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
508-
let k1 = substitute_value(self.tcx, result_subst, &ty::Binder::bind(*k1));
509-
let r2 = substitute_value(self.tcx, result_subst, &ty::Binder::bind(*r2));
509+
let constraint = substitute_value(self.tcx, result_subst, constraint);
510+
let &ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
510511

511512
Obligation::new(
512513
cause.clone(),
513514
param_env,
514-
match k1.skip_binder().unpack() {
515+
match k1.unpack() {
515516
UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives(
516517
ty::Binder::bind(
517-
ty::OutlivesPredicate(r1, r2.skip_binder())
518+
ty::OutlivesPredicate(r1, r2)
518519
)
519520
),
520521
UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives(
521522
ty::Binder::bind(
522-
ty::OutlivesPredicate(t1, r2.skip_binder())
523+
ty::OutlivesPredicate(t1, r2)
523524
)
524525
),
525526
}

0 commit comments

Comments
 (0)