mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
propagate the compare_ty fn further up
This commit is contained in:
@@ -102,23 +102,15 @@ pub fn projection_declared_bounds_from_trait(
|
||||
self.declared_projection_bounds_from_trait(projection_ty)
|
||||
}
|
||||
|
||||
pub fn projection_bound(
|
||||
&self,
|
||||
projection_ty: ty::ProjectionTy<'tcx>,
|
||||
) -> VerifyBound<'tcx> {
|
||||
debug!(
|
||||
"projection_bound(projection_ty={:?})",
|
||||
projection_ty
|
||||
);
|
||||
pub fn projection_bound(&self, projection_ty: ty::ProjectionTy<'tcx>) -> VerifyBound<'tcx> {
|
||||
debug!("projection_bound(projection_ty={:?})", projection_ty);
|
||||
|
||||
// Search the env for where clauses like `P: 'a`.
|
||||
let mut declared_bounds =
|
||||
self.declared_generic_bounds_from_env(GenericKind::Projection(projection_ty));
|
||||
|
||||
// Extend with bounds that we can find from the trait.
|
||||
declared_bounds.extend(
|
||||
self.projection_declared_bounds_from_trait(projection_ty)
|
||||
);
|
||||
declared_bounds.extend(self.projection_declared_bounds_from_trait(projection_ty));
|
||||
|
||||
debug!("projection_bound: declared_bounds = {:?}", declared_bounds);
|
||||
|
||||
@@ -158,6 +150,14 @@ fn recursive_type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
|
||||
fn declared_generic_bounds_from_env(
|
||||
&self,
|
||||
generic: GenericKind<'tcx>,
|
||||
) -> Vec<ty::Region<'tcx>> {
|
||||
let generic_ty = generic.to_ty(self.tcx);
|
||||
self.declared_generic_bounds_from_env_with_compare_fn(|ty| ty == generic_ty)
|
||||
}
|
||||
|
||||
fn declared_generic_bounds_from_env_with_compare_fn(
|
||||
&self,
|
||||
compare_ty: impl Fn(Ty<'tcx>) -> bool,
|
||||
) -> Vec<ty::Region<'tcx>> {
|
||||
let tcx = self.tcx;
|
||||
|
||||
@@ -167,12 +167,8 @@ fn declared_generic_bounds_from_env(
|
||||
// dubious for projections, but it will work for simple cases
|
||||
// like `T` and `T::Item`. It may not work as well for things
|
||||
// like `<T as Foo<'a>>::Item`.
|
||||
let generic_ty = generic.to_ty(tcx);
|
||||
let c_b = self.param_env.caller_bounds;
|
||||
let mut param_bounds = self.collect_outlives_from_predicate_list(
|
||||
|ty| ty == generic_ty,
|
||||
c_b,
|
||||
);
|
||||
let mut param_bounds = self.collect_outlives_from_predicate_list(&compare_ty, c_b);
|
||||
|
||||
// Next, collect regions we scraped from the well-formedness
|
||||
// constraints in the fn signature. To do that, we walk the list
|
||||
@@ -186,8 +182,11 @@ fn declared_generic_bounds_from_env(
|
||||
// well-formed, then, A must be lower-generic by `'a`, but we
|
||||
// don't know that this holds from first principles.
|
||||
for &(r, p) in self.region_bound_pairs {
|
||||
debug!("generic={:?} p={:?}", generic, p);
|
||||
if generic == p {
|
||||
debug!(
|
||||
"declared_generic_bounds_from_env_with_compare_fn: region_bound_pair = {:?}",
|
||||
(r, p)
|
||||
);
|
||||
if compare_ty(p.to_ty(tcx)) {
|
||||
param_bounds.push(r);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user