Skip to content

Commit 505d05d

Browse files
authored
Rollup merge of #107755 - lcnr:no-binder, r=oli-obk
remove binder from query constraints r? types
2 parents 26b532f + a04f31d commit 505d05d

File tree

3 files changed

+20
-39
lines changed

3 files changed

+20
-39
lines changed

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,8 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
8383
}
8484
self.constraints.member_constraints = tmp;
8585

86-
for (predicate, constraint_category) in outlives {
87-
// At the moment, we never generate any "higher-ranked"
88-
// region constraints like `for<'a> 'a: 'b`. At some point
89-
// when we move to universes, we will, and this assertion
90-
// will start to fail.
91-
let predicate = predicate.no_bound_vars().unwrap_or_else(|| {
92-
bug!("query_constraint {:?} contained bound vars", predicate,);
93-
});
94-
95-
self.convert(predicate, *constraint_category);
86+
for &(predicate, constraint_category) in outlives {
87+
self.convert(predicate, constraint_category);
9688
}
9789
}
9890

compiler/rustc_infer/src/infer/canonical/query_response.rs

+16-25
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,12 @@ impl<'tcx> InferCtxt<'tcx> {
268268
(GenericArgKind::Lifetime(v_o), GenericArgKind::Lifetime(v_r)) => {
269269
// To make `v_o = v_r`, we emit `v_o: v_r` and `v_r: v_o`.
270270
if v_o != v_r {
271-
output_query_region_constraints.outlives.push((
272-
ty::Binder::dummy(ty::OutlivesPredicate(v_o.into(), v_r)),
273-
constraint_category,
274-
));
275-
output_query_region_constraints.outlives.push((
276-
ty::Binder::dummy(ty::OutlivesPredicate(v_r.into(), v_o)),
277-
constraint_category,
278-
));
271+
output_query_region_constraints
272+
.outlives
273+
.push((ty::OutlivesPredicate(v_o.into(), v_r), constraint_category));
274+
output_query_region_constraints
275+
.outlives
276+
.push((ty::OutlivesPredicate(v_r.into(), v_o), constraint_category));
279277
}
280278
}
281279

@@ -318,10 +316,8 @@ impl<'tcx> InferCtxt<'tcx> {
318316
query_response.value.region_constraints.outlives.iter().filter_map(|&r_c| {
319317
let r_c = substitute_value(self.tcx, &result_subst, r_c);
320318

321-
// Screen out `'a: 'a` cases -- we skip the binder here but
322-
// only compare the inner values to one another, so they are still at
323-
// consistent binding levels.
324-
let ty::OutlivesPredicate(k1, r2) = r_c.0.skip_binder();
319+
// Screen out `'a: 'a` cases.
320+
let ty::OutlivesPredicate(k1, r2) = r_c.0;
325321
if k1 != r2.into() { Some(r_c) } else { None }
326322
}),
327323
);
@@ -559,11 +555,11 @@ impl<'tcx> InferCtxt<'tcx> {
559555

560556
pub fn query_outlives_constraint_to_obligation(
561557
&self,
562-
predicate: QueryOutlivesConstraint<'tcx>,
558+
(predicate, _): QueryOutlivesConstraint<'tcx>,
563559
cause: ObligationCause<'tcx>,
564560
param_env: ty::ParamEnv<'tcx>,
565561
) -> Obligation<'tcx, ty::Predicate<'tcx>> {
566-
let ty::OutlivesPredicate(k1, r2) = predicate.0.skip_binder();
562+
let ty::OutlivesPredicate(k1, r2) = predicate;
567563

568564
let atom = match k1.unpack() {
569565
GenericArgKind::Lifetime(r1) => {
@@ -578,7 +574,7 @@ impl<'tcx> InferCtxt<'tcx> {
578574
span_bug!(cause.span, "unexpected const outlives {:?}", predicate);
579575
}
580576
};
581-
let predicate = predicate.0.rebind(atom);
577+
let predicate = ty::Binder::dummy(atom);
582578

583579
Obligation::new(self.tcx, cause, param_env, predicate)
584580
}
@@ -643,8 +639,7 @@ pub fn make_query_region_constraints<'tcx>(
643639
let outlives: Vec<_> = constraints
644640
.iter()
645641
.map(|(k, origin)| {
646-
// no bound vars in the code above
647-
let constraint = ty::Binder::dummy(match *k {
642+
let constraint = match *k {
648643
// Swap regions because we are going from sub (<=) to outlives
649644
// (>=).
650645
Constraint::VarSubVar(v1, v2) => ty::OutlivesPredicate(
@@ -658,16 +653,12 @@ pub fn make_query_region_constraints<'tcx>(
658653
ty::OutlivesPredicate(tcx.mk_region(ty::ReVar(v2)).into(), r1)
659654
}
660655
Constraint::RegSubReg(r1, r2) => ty::OutlivesPredicate(r2.into(), r1),
661-
});
656+
};
662657
(constraint, origin.to_constraint_category())
663658
})
664-
.chain(
665-
outlives_obligations
666-
// no bound vars in the code above
667-
.map(|(ty, r, constraint_category)| {
668-
(ty::Binder::dummy(ty::OutlivesPredicate(ty.into(), r)), constraint_category)
669-
}),
670-
)
659+
.chain(outlives_obligations.map(|(ty, r, constraint_category)| {
660+
(ty::OutlivesPredicate(ty.into(), r), constraint_category)
661+
}))
671662
.collect();
672663

673664
QueryRegionConstraints { outlives, member_constraints: member_constraints.clone() }

compiler/rustc_middle/src/infer/canonical.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,8 @@ impl<'tcx, V> Canonical<'tcx, V> {
324324
}
325325
}
326326

327-
pub type QueryOutlivesConstraint<'tcx> = (
328-
ty::Binder<'tcx, ty::OutlivesPredicate<GenericArg<'tcx>, Region<'tcx>>>,
329-
ConstraintCategory<'tcx>,
330-
);
327+
pub type QueryOutlivesConstraint<'tcx> =
328+
(ty::OutlivesPredicate<GenericArg<'tcx>, Region<'tcx>>, ConstraintCategory<'tcx>);
331329

332330
TrivialTypeTraversalAndLiftImpls! {
333331
for <'tcx> {

0 commit comments

Comments
 (0)