]> git.lizzy.rs Git - rust.git/commitdiff
simply the IfEq bound -- we only ever use a region
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 15 Jun 2022 00:18:46 +0000 (20:18 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 15 Jun 2022 15:47:04 +0000 (11:47 -0400)
the excessive generality becomes annoying later because
it wouldn't implement type folding etc

compiler/rustc_borrowck/src/region_infer/mod.rs
compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
compiler/rustc_infer/src/infer/outlives/verify.rs
compiler/rustc_infer/src/infer/region_constraints/mod.rs

index 2c460bcb72d8b619c5babc3b204de5357d33b6cf..228e88b33cf2ed14a5fc6ab996e2ce14a763458d 100644 (file)
@@ -1170,9 +1170,14 @@ fn eval_verify_bound(
         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);
index 7975b946ee5ba0f48caf75f7a156edbaee8aff91..c5afd3762171d09809b5dc80bfc47b7d752f7047 100644 (file)
@@ -818,9 +818,9 @@ fn bound_is_met(
         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) => {
index 1c521c90686d6c0bf3392268bd405bd94fd29312..17681338a639b14af449ea466a48900e64a752a3 100644 (file)
@@ -160,14 +160,13 @@ pub fn projection_bound(
             .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)
                 }
             });
 
index efe254387dcc94957934758af86c2c626b8ee3ae..d7b4f450e0f8d7714865c254d834365749349f86 100644 (file)
@@ -224,7 +224,7 @@ pub enum VerifyBound<'tcx> {
     ///
     /// meaning, if the subject G is equal to `<T as Trait<'a>>::Item`
     /// (after inference), and `'a: min`, then `G: min`.
-    IfEq(Ty<'tcx>, Box<VerifyBound<'tcx>>),
+    IfEq(Ty<'tcx>, Region<'tcx>),
 
     /// Given a region `R`, expands to the function:
     ///
@@ -770,7 +770,7 @@ pub fn must_hold(&self) -> bool {
 
     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()),