mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Generalize a helper to be useful for types other than projections
This commit is contained in:
parent
96b819a456
commit
4d4cc4fe53
@ -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);
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user