Skip to content

Commit 4d4cc4f

Browse files
committed
Generalize a helper to be useful for types other than projections
1 parent 96b819a commit 4d4cc4f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,12 @@ where
347347

348348
debug!(?trait_bounds);
349349

350+
let generic = GenericKind::Projection(projection_ty);
351+
350352
// Compute the bounds we can derive from the environment. This
351353
// is an "approximate" match -- in some cases, these bounds
352354
// may not apply.
353-
let mut approx_env_bounds =
354-
self.verify_bound.projection_approx_declared_bounds_from_env(projection_ty);
355+
let mut approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(generic);
355356
debug!(?approx_env_bounds);
356357

357358
// Remove outlives bounds that we get from the environment but
@@ -436,7 +437,6 @@ where
436437
// projection outlive; in some cases, this may add insufficient
437438
// edges into the inference graph, leading to inference failures
438439
// even though a satisfactory solution exists.
439-
let generic = GenericKind::Projection(projection_ty);
440440
let verify_bound = self.verify_bound.generic_bound(generic);
441441
debug!("projection_must_outlive: pushing {:?}", verify_bound);
442442
self.delegate.push_verify(origin, generic, region, verify_bound);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
105105
/// the clause from the environment only applies if `'0 = 'a`,
106106
/// which we don't know yet. But we would still include `'b` in
107107
/// this list.
108-
pub fn projection_approx_declared_bounds_from_env(
108+
pub fn approx_declared_bounds_from_env(
109109
&self,
110-
projection_ty: ty::ProjectionTy<'tcx>,
110+
generic: GenericKind<'tcx>,
111111
) -> Vec<ty::Binder<'tcx, ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>>> {
112-
let projection_ty = GenericKind::Projection(projection_ty).to_ty(self.tcx);
112+
let projection_ty = generic.to_ty(self.tcx);
113113
let erased_projection_ty = self.tcx.erase_regions(projection_ty);
114114
self.declared_generic_bounds_from_env_for_erased_ty(erased_projection_ty)
115115
}
@@ -125,7 +125,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
125125

126126
// Search the env for where clauses like `P: 'a`.
127127
let env_bounds = self
128-
.projection_approx_declared_bounds_from_env(projection_ty)
128+
.approx_declared_bounds_from_env(GenericKind::Projection(projection_ty))
129129
.into_iter()
130130
.map(|binder| {
131131
if let Some(ty::OutlivesPredicate(ty, r)) = binder.no_bound_vars() && ty == projection_ty_as_ty {

0 commit comments

Comments
 (0)