Stop using ty::GenericPredicates for non-predicates_of queries

This commit is contained in:
Michael Goulet 2024-08-29 00:17:40 -04:00
parent ac77e88f7a
commit 92004523db
20 changed files with 101 additions and 98 deletions

View file

@ -185,12 +185,11 @@ fn predicates_reference_self(
) -> SmallVec<[Span; 1]> {
let trait_ref = ty::Binder::dummy(ty::TraitRef::identity(tcx, trait_def_id));
let predicates = if supertraits_only {
tcx.explicit_super_predicates_of(trait_def_id)
tcx.explicit_super_predicates_of(trait_def_id).skip_binder()
} else {
tcx.predicates_of(trait_def_id)
tcx.predicates_of(trait_def_id).predicates
};
predicates
.predicates
.iter()
.map(|&(predicate, sp)| (predicate.instantiate_supertrait(tcx, trait_ref), sp))
.filter_map(|(clause, sp)| {
@ -266,9 +265,8 @@ fn super_predicates_have_non_lifetime_binders(
return SmallVec::new();
}
tcx.explicit_super_predicates_of(trait_def_id)
.predicates
.iter()
.filter_map(|(pred, span)| pred.has_non_region_bound_vars().then_some(*span))
.iter_identity_copied()
.filter_map(|(pred, span)| pred.has_non_region_bound_vars().then_some(span))
.collect()
}

View file

@ -600,21 +600,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// Check supertraits hold. This is so that their associated type bounds
// will be checked in the code below.
for super_trait in tcx
for (supertrait, _) in tcx
.explicit_super_predicates_of(trait_predicate.def_id())
.instantiate(tcx, trait_predicate.trait_ref.args)
.predicates
.into_iter()
.iter_instantiated_copied(tcx, trait_predicate.trait_ref.args)
{
let normalized_super_trait = normalize_with_depth_to(
let normalized_supertrait = normalize_with_depth_to(
self,
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
super_trait,
supertrait,
&mut nested,
);
nested.push(obligation.with(tcx, normalized_super_trait));
nested.push(obligation.with(tcx, normalized_supertrait));
}
let assoc_types: Vec<_> = tcx

View file

@ -131,7 +131,7 @@ impl<'tcx> TraitAliasExpander<'tcx> {
let predicates = tcx.explicit_super_predicates_of(trait_ref.def_id());
debug!(?predicates);
let items = predicates.predicates.iter().rev().filter_map(|(pred, span)| {
let items = predicates.skip_binder().iter().rev().filter_map(|(pred, span)| {
pred.instantiate_supertrait(tcx, trait_ref)
.as_trait_clause()
.map(|trait_ref| item.clone_and_push(trait_ref.map_bound(|t| t.trait_ref), *span))

View file

@ -120,8 +120,7 @@ fn prepare_vtable_segments_inner<'tcx, T>(
let mut direct_super_traits_iter = tcx
.explicit_super_predicates_of(inner_most_trait_ref.def_id())
.predicates
.into_iter()
.iter_identity_copied()
.filter_map(move |(pred, _)| {
pred.instantiate_supertrait(tcx, inner_most_trait_ref).as_trait_clause()
});