1
Fork 0

change usages of explicit_item_bounds to bound_explicit_item_bounds

This commit is contained in:
Kyle Matsuda 2023-04-17 15:57:29 -06:00
parent a57fa08f48
commit 0892a7380b
13 changed files with 75 additions and 49 deletions

View file

@ -319,9 +319,12 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
selftys: vec![],
};
let prohibit_opaque = tcx
.explicit_item_bounds(def_id)
.iter()
.try_for_each(|(predicate, _)| predicate.visit_with(&mut visitor));
.bound_explicit_item_bounds(def_id.to_def_id())
.transpose_iter()
.try_for_each(|bound| {
let predicate = bound.map_bound(|&(predicate, _)| predicate).subst_identity();
predicate.visit_with(&mut visitor)
});
if let Some(ty) = prohibit_opaque.break_value() {
visitor.visit_item(&item);

View file

@ -360,7 +360,10 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
tcx,
param_env,
item_def_id,
tcx.explicit_item_bounds(item_def_id).to_vec(),
tcx.bound_explicit_item_bounds(item_def_id.to_def_id())
.transpose_iter()
.map(|bound| bound.map_bound(|b| *b).subst_identity())
.collect::<Vec<_>>(),
&FxIndexSet::default(),
gat_def_id.def_id,
gat_generics,
@ -1122,10 +1125,11 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
/// Assuming the defaults are used, check that all predicates (bounds on the
/// assoc type and where clauses on the trait) hold.
fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocItem, span: Span) {
let bounds = wfcx.tcx().explicit_item_bounds(item.def_id);
let bounds = wfcx.tcx().bound_explicit_item_bounds(item.def_id);
debug!("check_associated_type_bounds: bounds={:?}", bounds);
let wf_obligations = bounds.iter().flat_map(|&(bound, bound_span)| {
let wf_obligations = bounds.transpose_iter().flat_map(|b| {
let (bound, bound_span) = b.map_bound(|b| *b).subst_identity();
let normalized_bound = wfcx.normalize(span, None, bound);
traits::wf::predicate_obligations(
wfcx.infcx,

View file

@ -130,9 +130,10 @@ pub(super) fn item_bounds(
tcx: TyCtxt<'_>,
def_id: DefId,
) -> ty::EarlyBinder<&'_ ty::List<ty::Predicate<'_>>> {
let bounds = tcx.mk_predicates_from_iter(util::elaborate(
tcx,
tcx.explicit_item_bounds(def_id).iter().map(|&(bound, _span)| bound),
));
ty::EarlyBinder(bounds)
tcx.bound_explicit_item_bounds(def_id).map_bound(|bounds| {
tcx.mk_predicates_from_iter(util::elaborate(
tcx,
bounds.iter().map(|&(bound, _span)| bound),
))
})
}