Skip to content

Commit d203c13

Browse files
committed
simply the IfEq bound -- we only ever use a region
the excessive generality becomes annoying later because it wouldn't implement type folding etc
1 parent 1f34da9 commit d203c13

File tree

4 files changed

+14
-10
lines changed
  • compiler

4 files changed

+14
-10
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,9 +1170,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11701170
debug!("eval_verify_bound(lower_bound={:?}, verify_bound={:?})", lower_bound, verify_bound);
11711171

11721172
match verify_bound {
1173-
VerifyBound::IfEq(test_ty, verify_bound1) => {
1174-
self.eval_if_eq(tcx, body, generic_ty, lower_bound, *test_ty, verify_bound1)
1175-
}
1173+
VerifyBound::IfEq(test_ty, verify_bound1) => self.eval_if_eq(
1174+
tcx,
1175+
body,
1176+
generic_ty,
1177+
lower_bound,
1178+
*test_ty,
1179+
&VerifyBound::OutlivedBy(*verify_bound1),
1180+
),
11761181

11771182
VerifyBound::IsEmpty => {
11781183
let lower_bound_scc = self.constraint_sccs.scc(lower_bound);

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
818818
min: ty::Region<'tcx>,
819819
) -> bool {
820820
match bound {
821-
VerifyBound::IfEq(k, b) => {
821+
VerifyBound::IfEq(k, r) => {
822822
(var_values.normalize(self.region_rels.tcx, *k) == generic_ty)
823-
&& self.bound_is_met(b, var_values, generic_ty, min)
823+
&& self.bound_is_met(&VerifyBound::OutlivedBy(*r), var_values, generic_ty, min)
824824
}
825825

826826
VerifyBound::OutlivedBy(r) => {

compiler/rustc_infer/src/infer/outlives/verify.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,13 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
160160
.projection_approx_declared_bounds_from_env(projection_ty)
161161
.into_iter()
162162
.map(|ty::OutlivesPredicate(ty, r)| {
163-
let vb = VerifyBound::OutlivedBy(r);
164163
if ty == projection_ty_as_ty {
165164
// Micro-optimize if this is an exact match (this
166165
// occurs often when there are no region variables
167166
// involved).
168-
vb
167+
VerifyBound::OutlivedBy(r)
169168
} else {
170-
VerifyBound::IfEq(ty, Box::new(vb))
169+
VerifyBound::IfEq(ty, r)
171170
}
172171
});
173172

compiler/rustc_infer/src/infer/region_constraints/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ pub enum VerifyBound<'tcx> {
224224
///
225225
/// meaning, if the subject G is equal to `<T as Trait<'a>>::Item`
226226
/// (after inference), and `'a: min`, then `G: min`.
227-
IfEq(Ty<'tcx>, Box<VerifyBound<'tcx>>),
227+
IfEq(Ty<'tcx>, Region<'tcx>),
228228

229229
/// Given a region `R`, expands to the function:
230230
///
@@ -770,7 +770,7 @@ impl<'tcx> VerifyBound<'tcx> {
770770

771771
pub fn cannot_hold(&self) -> bool {
772772
match self {
773-
VerifyBound::IfEq(_, b) => b.cannot_hold(),
773+
VerifyBound::IfEq(_, _) => false,
774774
VerifyBound::IsEmpty => false,
775775
VerifyBound::OutlivedBy(_) => false,
776776
VerifyBound::AnyBound(bs) => bs.iter().all(|b| b.cannot_hold()),

0 commit comments

Comments
 (0)