Anonymize late bound regions on transitive bounds that define assoc type
This commit is contained in:
parent
fd092557ce
commit
8d17c6a85d
2 changed files with 54 additions and 14 deletions
|
@ -292,26 +292,33 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
||||||
assoc_name: Ident,
|
assoc_name: Ident,
|
||||||
) -> FxIndexSet<ty::PolyTraitRef<'tcx>> {
|
) -> impl Iterator<Item = ty::PolyTraitRef<'tcx>> {
|
||||||
let mut stack: Vec<_> = bounds.collect();
|
let mut stack: Vec<_> = bounds.collect();
|
||||||
let mut trait_refs = FxIndexSet::default();
|
let mut visited = FxIndexSet::default();
|
||||||
|
|
||||||
while let Some(trait_ref) = stack.pop() {
|
std::iter::from_fn(move || {
|
||||||
if trait_refs.insert(trait_ref) {
|
while let Some(trait_ref) = stack.pop() {
|
||||||
let super_predicates =
|
let anon_trait_ref = tcx.anonymize_late_bound_regions(trait_ref);
|
||||||
tcx.super_predicates_that_define_assoc_type((trait_ref.def_id(), Some(assoc_name)));
|
if visited.insert(anon_trait_ref) {
|
||||||
for (super_predicate, _) in super_predicates.predicates {
|
let super_predicates = tcx.super_predicates_that_define_assoc_type((
|
||||||
let bound_predicate = super_predicate.kind();
|
trait_ref.def_id(),
|
||||||
let subst_predicate = super_predicate
|
Some(assoc_name),
|
||||||
.subst_supertrait(tcx, &bound_predicate.rebind(trait_ref.skip_binder()));
|
));
|
||||||
if let Some(binder) = subst_predicate.to_opt_poly_trait_ref() {
|
for (super_predicate, _) in super_predicates.predicates {
|
||||||
stack.push(binder.value);
|
let bound_predicate = super_predicate.kind();
|
||||||
|
let subst_predicate = super_predicate
|
||||||
|
.subst_supertrait(tcx, &bound_predicate.rebind(trait_ref.skip_binder()));
|
||||||
|
if let Some(binder) = subst_predicate.to_opt_poly_trait_ref() {
|
||||||
|
stack.push(binder.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Some(trait_ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
trait_refs
|
return None;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
pub struct LookupInternedStorage;
|
||||||
|
|
||||||
|
impl<Q> QueryStorageOps<Q> for LookupInternedStorage
|
||||||
|
where
|
||||||
|
Q: Query,
|
||||||
|
for<'d> Q: QueryDb<'d>,
|
||||||
|
{
|
||||||
|
fn fmt_index(&self, db: &<Q as QueryDb<'_>>::DynDb) {
|
||||||
|
<<Q as QueryDb<'_>>::DynDb as HasQueryGroup<Q::Group>>::group_storage(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait HasQueryGroup<G> {
|
||||||
|
fn group_storage(&self);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait QueryStorageOps<Q>
|
||||||
|
where
|
||||||
|
Q: Query,
|
||||||
|
{
|
||||||
|
fn fmt_index(&self, db: &<Q as QueryDb<'_>>::DynDb);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait QueryDb<'d> {
|
||||||
|
type DynDb: HasQueryGroup<Self::Group> + 'd;
|
||||||
|
type Group;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Query: for<'d> QueryDb<'d> {}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue