about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-05-18 15:17:58 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-09-21 12:51:33 +0000
commit4d4cc4fe53aec2a7f36535c3458aced2fcd2988d (patch)
tree13dd8e2875d3e5071b84d8cdd79e777238235a00
parent96b819a456672e50444dcccbfed2435f6b212225 (diff)
downloadrust-4d4cc4fe53aec2a7f36535c3458aced2fcd2988d.tar.gz
rust-4d4cc4fe53aec2a7f36535c3458aced2fcd2988d.zip
Generalize a helper to be useful for types other than projections
-rw-r--r--compiler/rustc_infer/src/infer/outlives/obligations.rs6
-rw-r--r--compiler/rustc_infer/src/infer/outlives/verify.rs8
2 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs
index 3f98168e257..ec26a10c536 100644
--- a/compiler/rustc_infer/src/infer/outlives/obligations.rs
+++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs
@@ -347,11 +347,12 @@ where
 
         debug!(?trait_bounds);
 
+        let generic = GenericKind::Projection(projection_ty);
+
         // Compute the bounds we can derive from the environment. This
         // is an "approximate" match -- in some cases, these bounds
         // may not apply.
-        let mut approx_env_bounds =
-            self.verify_bound.projection_approx_declared_bounds_from_env(projection_ty);
+        let mut approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(generic);
         debug!(?approx_env_bounds);
 
         // Remove outlives bounds that we get from the environment but
@@ -436,7 +437,6 @@ where
         // projection outlive; in some cases, this may add insufficient
         // edges into the inference graph, leading to inference failures
         // even though a satisfactory solution exists.
-        let generic = GenericKind::Projection(projection_ty);
         let verify_bound = self.verify_bound.generic_bound(generic);
         debug!("projection_must_outlive: pushing {:?}", verify_bound);
         self.delegate.push_verify(origin, generic, region, verify_bound);
diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs
index 30ee1229fae..5f1671b4807 100644
--- a/compiler/rustc_infer/src/infer/outlives/verify.rs
+++ b/compiler/rustc_infer/src/infer/outlives/verify.rs
@@ -105,11 +105,11 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
     /// the clause from the environment only applies if `'0 = 'a`,
     /// which we don't know yet. But we would still include `'b` in
     /// this list.
-    pub fn projection_approx_declared_bounds_from_env(
+    pub fn approx_declared_bounds_from_env(
         &self,
-        projection_ty: ty::ProjectionTy<'tcx>,
+        generic: GenericKind<'tcx>,
     ) -> Vec<ty::Binder<'tcx, ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>>> {
-        let projection_ty = GenericKind::Projection(projection_ty).to_ty(self.tcx);
+        let projection_ty = generic.to_ty(self.tcx);
         let erased_projection_ty = self.tcx.erase_regions(projection_ty);
         self.declared_generic_bounds_from_env_for_erased_ty(erased_projection_ty)
     }
@@ -125,7 +125,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
 
         // Search the env for where clauses like `P: 'a`.
         let env_bounds = self
-            .projection_approx_declared_bounds_from_env(projection_ty)
+            .approx_declared_bounds_from_env(GenericKind::Projection(projection_ty))
             .into_iter()
             .map(|binder| {
                 if let Some(ty::OutlivesPredicate(ty, r)) = binder.no_bound_vars() && ty == projection_ty_as_ty {