Skip to content

Commit c5ed72f

Browse files
committed
Substitute binders directly
1 parent 0751997 commit c5ed72f

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
}
@@ -530,22 +532,21 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
530532
unsubstituted_region_constraints
531533
.iter()
532534
.map(move |constraint| {
533-
let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
534-
let k1 = substitute_value(self.tcx, result_subst, &ty::Binder::bind(*k1));
535-
let r2 = substitute_value(self.tcx, result_subst, &ty::Binder::bind(*r2));
535+
let constraint = substitute_value(self.tcx, result_subst, constraint);
536+
let &ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
536537

537538
Obligation::new(
538539
cause.clone(),
539540
param_env,
540-
match k1.skip_binder().unpack() {
541+
match k1.unpack() {
541542
UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives(
542543
ty::Binder::bind(
543-
ty::OutlivesPredicate(r1, r2.skip_binder())
544+
ty::OutlivesPredicate(r1, r2)
544545
)
545546
),
546547
UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives(
547548
ty::Binder::bind(
548-
ty::OutlivesPredicate(t1, r2.skip_binder())
549+
ty::OutlivesPredicate(t1, r2)
549550
)
550551
),
551552
}

0 commit comments

Comments
 (0)