diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 2c460bcb72d..228e88b33cf 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -1170,9 +1170,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { debug!("eval_verify_bound(lower_bound={:?}, verify_bound={:?})", lower_bound, verify_bound); match verify_bound { - VerifyBound::IfEq(test_ty, verify_bound1) => { - self.eval_if_eq(tcx, body, generic_ty, lower_bound, *test_ty, verify_bound1) - } + VerifyBound::IfEq(test_ty, verify_bound1) => self.eval_if_eq( + tcx, + body, + generic_ty, + lower_bound, + *test_ty, + &VerifyBound::OutlivedBy(*verify_bound1), + ), VerifyBound::IsEmpty => { let lower_bound_scc = self.constraint_sccs.scc(lower_bound); diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs index 7975b946ee5..c5afd376217 100644 --- a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs +++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs @@ -818,9 +818,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { min: ty::Region<'tcx>, ) -> bool { match bound { - VerifyBound::IfEq(k, b) => { + VerifyBound::IfEq(k, r) => { (var_values.normalize(self.region_rels.tcx, *k) == generic_ty) - && self.bound_is_met(b, var_values, generic_ty, min) + && self.bound_is_met(&VerifyBound::OutlivedBy(*r), var_values, generic_ty, min) } VerifyBound::OutlivedBy(r) => { diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs index 1c521c90686..17681338a63 100644 --- a/compiler/rustc_infer/src/infer/outlives/verify.rs +++ b/compiler/rustc_infer/src/infer/outlives/verify.rs @@ -160,14 +160,13 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { .projection_approx_declared_bounds_from_env(projection_ty) .into_iter() .map(|ty::OutlivesPredicate(ty, r)| { - let vb = VerifyBound::OutlivedBy(r); if ty == projection_ty_as_ty { // Micro-optimize if this is an exact match (this // occurs often when there are no region variables // involved). - vb + VerifyBound::OutlivedBy(r) } else { - VerifyBound::IfEq(ty, Box::new(vb)) + VerifyBound::IfEq(ty, r) } }); diff --git a/compiler/rustc_infer/src/infer/region_constraints/mod.rs b/compiler/rustc_infer/src/infer/region_constraints/mod.rs index efe254387dc..d7b4f450e0f 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/mod.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/mod.rs @@ -224,7 +224,7 @@ pub enum VerifyBound<'tcx> { /// /// meaning, if the subject G is equal to `>::Item` /// (after inference), and `'a: min`, then `G: min`. - IfEq(Ty<'tcx>, Box>), + IfEq(Ty<'tcx>, Region<'tcx>), /// Given a region `R`, expands to the function: /// @@ -770,7 +770,7 @@ impl<'tcx> VerifyBound<'tcx> { pub fn cannot_hold(&self) -> bool { match self { - VerifyBound::IfEq(_, b) => b.cannot_hold(), + VerifyBound::IfEq(_, _) => false, VerifyBound::IsEmpty => false, VerifyBound::OutlivedBy(_) => false, VerifyBound::AnyBound(bs) => bs.iter().all(|b| b.cannot_hold()),