1
Fork 0

add EarlyBinder to output of explicit_item_bounds; replace bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query

This commit is contained in:
Kyle Matsuda 2023-04-17 16:43:46 -06:00
parent 0892a7380b
commit f3b279fcc5
26 changed files with 49 additions and 56 deletions

View file

@ -706,7 +706,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
.copied() .copied()
.find_map(find_fn_kind_from_did), .find_map(find_fn_kind_from_did),
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => tcx ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => tcx
.bound_explicit_item_bounds(def_id) .explicit_item_bounds(def_id)
.subst_iter_copied(tcx, substs) .subst_iter_copied(tcx, substs)
.find_map(find_fn_kind_from_did), .find_map(find_fn_kind_from_did),
ty::Closure(_, substs) => match substs.as_closure().kind() { ty::Closure(_, substs) => match substs.as_closure().kind() {

View file

@ -318,10 +318,8 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
tcx, tcx,
selftys: vec![], selftys: vec![],
}; };
let prohibit_opaque = tcx let prohibit_opaque =
.bound_explicit_item_bounds(def_id.to_def_id()) tcx.explicit_item_bounds(def_id).transpose_iter().try_for_each(|bound| {
.transpose_iter()
.try_for_each(|bound| {
let predicate = bound.map_bound(|&(predicate, _)| predicate).subst_identity(); let predicate = bound.map_bound(|&(predicate, _)| predicate).subst_identity();
predicate.visit_with(&mut visitor) predicate.visit_with(&mut visitor)
}); });

View file

@ -839,7 +839,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
}); });
self.types.insert(proj.def_id, (infer_ty, proj.substs)); self.types.insert(proj.def_id, (infer_ty, proj.substs));
// Recurse into bounds // Recurse into bounds
for (pred, pred_span) in self.interner().bound_explicit_item_bounds(proj.def_id).subst_iter_copied(self.interner(), proj.substs) { for (pred, pred_span) in self.interner().explicit_item_bounds(proj.def_id).subst_iter_copied(self.interner(), proj.substs) {
let pred = pred.fold_with(self); let pred = pred.fold_with(self);
let pred = self.ocx.normalize( let pred = self.ocx.normalize(
&ObligationCause::misc(self.span, self.body_id), &ObligationCause::misc(self.span, self.body_id),
@ -2023,7 +2023,7 @@ pub(super) fn check_type_bounds<'tcx>(
}; };
let obligations: Vec<_> = tcx let obligations: Vec<_> = tcx
.bound_explicit_item_bounds(trait_ty.def_id) .explicit_item_bounds(trait_ty.def_id)
.subst_iter_copied(tcx, rebased_substs) .subst_iter_copied(tcx, rebased_substs)
.map(|(concrete_ty_bound, span)| { .map(|(concrete_ty_bound, span)| {
debug!("check_type_bounds: concrete_ty_bound = {:?}", concrete_ty_bound); debug!("check_type_bounds: concrete_ty_bound = {:?}", concrete_ty_bound);

View file

@ -360,7 +360,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
tcx, tcx,
param_env, param_env,
item_def_id, item_def_id,
tcx.bound_explicit_item_bounds(item_def_id.to_def_id()) tcx.explicit_item_bounds(item_def_id)
.transpose_iter() .transpose_iter()
.map(|bound| bound.map_bound(|b| *b).subst_identity()) .map(|bound| bound.map_bound(|b| *b).subst_identity())
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
@ -1125,7 +1125,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
/// Assuming the defaults are used, check that all predicates (bounds on the /// Assuming the defaults are used, check that all predicates (bounds on the
/// assoc type and where clauses on the trait) hold. /// assoc type and where clauses on the trait) hold.
fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocItem, span: Span) { fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocItem, span: Span) {
let bounds = wfcx.tcx().bound_explicit_item_bounds(item.def_id); let bounds = wfcx.tcx().explicit_item_bounds(item.def_id);
debug!("check_associated_type_bounds: bounds={:?}", bounds); debug!("check_associated_type_bounds: bounds={:?}", bounds);
let wf_obligations = bounds.transpose_iter().flat_map(|b| { let wf_obligations = bounds.transpose_iter().flat_map(|b| {
@ -1592,7 +1592,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
} }
}); });
for (bound, bound_span) in tcx for (bound, bound_span) in tcx
.bound_explicit_item_bounds(opaque_ty.def_id) .explicit_item_bounds(opaque_ty.def_id)
.subst_iter_copied(tcx, opaque_ty.substs) .subst_iter_copied(tcx, opaque_ty.substs)
{ {
let bound = self.wfcx.normalize(bound_span, None, bound); let bound = self.wfcx.normalize(bound_span, None, bound);

View file

@ -79,14 +79,14 @@ fn opaque_type_bounds<'tcx>(
pub(super) fn explicit_item_bounds( pub(super) fn explicit_item_bounds(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
def_id: LocalDefId, def_id: LocalDefId,
) -> &'_ [(ty::Predicate<'_>, Span)] { ) -> ty::EarlyBinder<&'_ [(ty::Predicate<'_>, Span)]> {
match tcx.opt_rpitit_info(def_id.to_def_id()) { match tcx.opt_rpitit_info(def_id.to_def_id()) {
// RPITIT's bounds are the same as opaque type bounds, but with // RPITIT's bounds are the same as opaque type bounds, but with
// a projection self type. // a projection self type.
Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => { Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => {
let item = tcx.hir().get_by_def_id(opaque_def_id.expect_local()).expect_item(); let item = tcx.hir().get_by_def_id(opaque_def_id.expect_local()).expect_item();
let opaque_ty = item.expect_opaque_ty(); let opaque_ty = item.expect_opaque_ty();
return opaque_type_bounds( return ty::EarlyBinder(opaque_type_bounds(
tcx, tcx,
opaque_def_id.expect_local(), opaque_def_id.expect_local(),
opaque_ty.bounds, opaque_ty.bounds,
@ -95,7 +95,7 @@ pub(super) fn explicit_item_bounds(
ty::InternalSubsts::identity_for_item(tcx, def_id), ty::InternalSubsts::identity_for_item(tcx, def_id),
), ),
item.span, item.span,
); ));
} }
// These should have been fed! // These should have been fed!
Some(ty::ImplTraitInTraitData::Impl { .. }) => unreachable!(), Some(ty::ImplTraitInTraitData::Impl { .. }) => unreachable!(),
@ -103,7 +103,7 @@ pub(super) fn explicit_item_bounds(
} }
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
match tcx.hir().get(hir_id) { let bounds = match tcx.hir().get(hir_id) {
hir::Node::TraitItem(hir::TraitItem { hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Type(bounds, _), kind: hir::TraitItemKind::Type(bounds, _),
span, span,
@ -123,14 +123,15 @@ pub(super) fn explicit_item_bounds(
opaque_type_bounds(tcx, def_id, bounds, item_ty, *span) opaque_type_bounds(tcx, def_id, bounds, item_ty, *span)
} }
_ => bug!("item_bounds called on {:?}", def_id), _ => bug!("item_bounds called on {:?}", def_id),
} };
ty::EarlyBinder(bounds)
} }
pub(super) fn item_bounds( pub(super) fn item_bounds(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
def_id: DefId, def_id: DefId,
) -> ty::EarlyBinder<&'_ ty::List<ty::Predicate<'_>>> { ) -> ty::EarlyBinder<&'_ ty::List<ty::Predicate<'_>>> {
tcx.bound_explicit_item_bounds(def_id).map_bound(|bounds| { tcx.explicit_item_bounds(def_id).map_bound(|bounds| {
tcx.mk_predicates_from_iter(util::elaborate( tcx.mk_predicates_from_iter(util::elaborate(
tcx, tcx,
bounds.iter().map(|&(bound, _span)| bound), bounds.iter().map(|&(bound, _span)| bound),

View file

@ -153,7 +153,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
let mut collector = let mut collector =
OpaqueTypeLifetimeCollector { tcx, root_def_id: item_def_id.to_def_id(), variances }; OpaqueTypeLifetimeCollector { tcx, root_def_id: item_def_id.to_def_id(), variances };
let id_substs = ty::InternalSubsts::identity_for_item(tcx, item_def_id); let id_substs = ty::InternalSubsts::identity_for_item(tcx, item_def_id);
for pred in tcx.bound_explicit_item_bounds(item_def_id.to_def_id()).transpose_iter() { for pred in tcx.explicit_item_bounds(item_def_id).transpose_iter() {
let pred = pred.map_bound(|(pred, _)| *pred).subst(tcx, id_substs); let pred = pred.map_bound(|(pred, _)| *pred).subst(tcx, id_substs);
debug!(?pred); debug!(?pred);

View file

@ -530,7 +530,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for ty in [first_ty, second_ty] { for ty in [first_ty, second_ty] {
for (pred, _) in self for (pred, _) in self
.tcx .tcx
.bound_explicit_item_bounds(rpit_def_id) .explicit_item_bounds(rpit_def_id)
.subst_iter_copied(self.tcx, substs) .subst_iter_copied(self.tcx, substs)
{ {
let pred = pred.kind().rebind(match pred.kind().skip_binder() { let pred = pred.kind().rebind(match pred.kind().skip_binder() {

View file

@ -172,7 +172,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => self ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => self
.deduce_closure_signature_from_predicates( .deduce_closure_signature_from_predicates(
expected_ty, expected_ty,
self.tcx.bound_explicit_item_bounds(def_id).subst_iter_copied(self.tcx, substs), self.tcx.explicit_item_bounds(def_id).subst_iter_copied(self.tcx, substs),
), ),
ty::Dynamic(ref object_type, ..) => { ty::Dynamic(ref object_type, ..) => {
let sig = object_type.projection_bounds().find_map(|pb| { let sig = object_type.projection_bounds().find_map(|pb| {
@ -713,13 +713,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => self ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => self
.tcx .tcx
.bound_explicit_item_bounds(def_id) .explicit_item_bounds(def_id)
.subst_iter_copied(self.tcx, substs) .subst_iter_copied(self.tcx, substs)
.find_map(|(p, s)| get_future_output(p, s))?, .find_map(|(p, s)| get_future_output(p, s))?,
ty::Error(_) => return None, ty::Error(_) => return None,
ty::Alias(ty::Projection, proj) if self.tcx.is_impl_trait_in_trait(proj.def_id) => self ty::Alias(ty::Projection, proj) if self.tcx.is_impl_trait_in_trait(proj.def_id) => self
.tcx .tcx
.bound_explicit_item_bounds(proj.def_id) .explicit_item_bounds(proj.def_id)
.subst_iter_copied(self.tcx, proj.substs) .subst_iter_copied(self.tcx, proj.substs)
.find_map(|(p, s)| get_future_output(p, s))?, .find_map(|(p, s)| get_future_output(p, s))?,
_ => span_bug!( _ => span_bug!(

View file

@ -571,8 +571,8 @@ fn check_must_not_suspend_ty<'tcx>(
// FIXME: support adding the attribute to TAITs // FIXME: support adding the attribute to TAITs
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => { ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
let mut has_emitted = false; let mut has_emitted = false;
for bound in fcx.tcx.bound_explicit_item_bounds(def).transpose_iter() { for bound in fcx.tcx.explicit_item_bounds(def).transpose_iter() {
let predicate = bound.map_bound(|&(predicate, _)| predicate).subst_identity(); let predicate = bound.map_bound(|&(pred, _)| pred).subst_identity();
// We only look at the `DefId`, so it is safe to skip the binder here. // We only look at the `DefId`, so it is safe to skip the binder here.
if let ty::PredicateKind::Clause(ty::Clause::Trait(ref poly_trait_predicate)) = if let ty::PredicateKind::Clause(ty::Clause::Trait(ref poly_trait_predicate)) =
predicate.kind().skip_binder() predicate.kind().skip_binder()

View file

@ -402,7 +402,7 @@ impl<'tcx> InferCtxt<'tcx> {
let future_trait = self.tcx.require_lang_item(LangItem::Future, None); let future_trait = self.tcx.require_lang_item(LangItem::Future, None);
let item_def_id = self.tcx.associated_item_def_ids(future_trait)[0]; let item_def_id = self.tcx.associated_item_def_ids(future_trait)[0];
self.tcx.bound_explicit_item_bounds(def_id).subst_iter_copied(self.tcx, substs).find_map( self.tcx.explicit_item_bounds(def_id).subst_iter_copied(self.tcx, substs).find_map(
|(predicate, _)| { |(predicate, _)| {
predicate predicate
.kind() .kind()

View file

@ -540,7 +540,7 @@ impl<'tcx> InferCtxt<'tcx> {
.obligations; .obligations;
} }
let item_bounds = tcx.bound_explicit_item_bounds(def_id.to_def_id()); let item_bounds = tcx.explicit_item_bounds(def_id);
for (predicate, _) in item_bounds.subst_iter_copied(tcx, substs) { for (predicate, _) in item_bounds.subst_iter_copied(tcx, substs) {
let predicate = predicate.fold_with(&mut BottomUpFolder { let predicate = predicate.fold_with(&mut BottomUpFolder {

View file

@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
// For every projection predicate in the opaque type's explicit bounds, // For every projection predicate in the opaque type's explicit bounds,
// check that the type that we're assigning actually satisfies the bounds // check that the type that we're assigning actually satisfies the bounds
// of the associated type. // of the associated type.
for bound in cx.tcx.bound_explicit_item_bounds(def_id).transpose_iter() { for bound in cx.tcx.explicit_item_bounds(def_id).transpose_iter() {
let (pred, pred_span) = bound.map_bound(|b| *b).subst_identity(); let (pred, pred_span) = bound.map_bound(|b| *b).subst_identity();
// Liberate bound regions in the predicate since we // Liberate bound regions in the predicate since we
@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
// with `impl Send: OtherTrait`. // with `impl Send: OtherTrait`.
for (assoc_pred, assoc_pred_span) in cx for (assoc_pred, assoc_pred_span) in cx
.tcx .tcx
.bound_explicit_item_bounds(proj.projection_ty.def_id) .explicit_item_bounds(proj.projection_ty.def_id)
.subst_iter_copied(cx.tcx, &proj.projection_ty.substs) .subst_iter_copied(cx.tcx, &proj.projection_ty.substs)
{ {
let assoc_pred = assoc_pred.fold_with(proj_replacer); let assoc_pred = assoc_pred.fold_with(proj_replacer);

View file

@ -257,7 +257,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
elaborate( elaborate(
cx.tcx, cx.tcx,
cx.tcx cx.tcx
.bound_explicit_item_bounds(def) .explicit_item_bounds(def)
.transpose_iter() .transpose_iter()
.map(|bound| bound.map_bound(|b| *b).subst_identity()), .map(|bound| bound.map_bound(|b| *b).subst_identity()),
) )

View file

@ -203,7 +203,11 @@ impl IntoArgs for (CrateNum, SimplifiedType) {
} }
provide! { tcx, def_id, other, cdata, provide! { tcx, def_id, other, cdata,
explicit_item_bounds => { table_defaulted_array } explicit_item_bounds => {
let lazy = cdata.root.tables.explicit_item_bounds.get(cdata, def_id.index);
let output = if lazy.is_default() { &mut [] } else { tcx.arena.alloc_from_iter(lazy.decode((cdata, tcx))) };
ty::EarlyBinder(&*output)
}
explicit_predicates_of => { table } explicit_predicates_of => { table }
generics_of => { table } generics_of => { table }
inferred_outlives_of => { table_defaulted_array } inferred_outlives_of => { table_defaulted_array }

View file

@ -1425,7 +1425,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
fn encode_explicit_item_bounds(&mut self, def_id: DefId) { fn encode_explicit_item_bounds(&mut self, def_id: DefId) {
debug!("EncodeContext::encode_explicit_item_bounds({:?})", def_id); debug!("EncodeContext::encode_explicit_item_bounds({:?})", def_id);
let bounds = self.tcx.explicit_item_bounds(def_id); let bounds = self.tcx.explicit_item_bounds(def_id).skip_binder();
record_defaulted_array!(self.tables.explicit_item_bounds[def_id] <- bounds); record_defaulted_array!(self.tables.explicit_item_bounds[def_id] <- bounds);
} }

View file

@ -274,7 +274,7 @@ rustc_queries! {
/// `key` is the `DefId` of the associated type or opaque type. /// `key` is the `DefId` of the associated type or opaque type.
/// ///
/// Bounds from the parent (e.g. with nested impl trait) are not included. /// Bounds from the parent (e.g. with nested impl trait) are not included.
query explicit_item_bounds(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] { query explicit_item_bounds(key: DefId) -> ty::EarlyBinder<&'tcx [(ty::Predicate<'tcx>, Span)]> {
desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) } desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() } cache_on_disk_if { key.is_local() }
separate_provide_extern separate_provide_extern

View file

@ -1611,7 +1611,7 @@ impl<'tcx> TyCtxt<'tcx> {
let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false }; let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false };
let future_trait = self.require_lang_item(LangItem::Future, None); let future_trait = self.require_lang_item(LangItem::Future, None);
self.bound_explicit_item_bounds(*def_id).skip_binder().iter().any(|(predicate, _)| { self.explicit_item_bounds(def_id).skip_binder().iter().any(|(predicate, _)| {
let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() else { let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() else {
return false; return false;
}; };

View file

@ -911,7 +911,7 @@ pub trait PrettyPrinter<'tcx>:
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`, // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
// by looking up the projections associated with the def_id. // by looking up the projections associated with the def_id.
let bounds = tcx.bound_explicit_item_bounds(def_id); let bounds = tcx.explicit_item_bounds(def_id);
let mut traits = FxIndexMap::default(); let mut traits = FxIndexMap::default();
let mut fn_traits = FxIndexMap::default(); let mut fn_traits = FxIndexMap::default();

View file

@ -694,13 +694,6 @@ impl<'tcx> TyCtxt<'tcx> {
if visitor.found_recursion { Err(expanded_type) } else { Ok(expanded_type) } if visitor.found_recursion { Err(expanded_type) } else { Ok(expanded_type) }
} }
pub fn bound_explicit_item_bounds(
self,
def_id: DefId,
) -> ty::EarlyBinder<&'tcx [(ty::Predicate<'tcx>, rustc_span::Span)]> {
ty::EarlyBinder(self.explicit_item_bounds(def_id))
}
/// Returns names of captured upvars for closures and generators. /// Returns names of captured upvars for closures and generators.
/// ///
/// Here are some examples: /// Here are some examples:

View file

@ -1800,7 +1800,7 @@ fn check_must_not_suspend_ty<'tcx>(
// FIXME: support adding the attribute to TAITs // FIXME: support adding the attribute to TAITs
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => { ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
let mut has_emitted = false; let mut has_emitted = false;
for bound in tcx.bound_explicit_item_bounds(def).transpose_iter() { for bound in tcx.explicit_item_bounds(def).transpose_iter() {
let predicate = bound.map_bound(|&(pred, _)| pred).subst_identity(); let predicate = bound.map_bound(|&(pred, _)| pred).subst_identity();
// We only look at the `DefId`, so it is safe to skip the binder here. // We only look at the `DefId`, so it is safe to skip the binder here.

View file

@ -269,7 +269,7 @@ where
// and are visited by shallow visitors. // and are visited by shallow visitors.
self.visit_predicates(ty::GenericPredicates { self.visit_predicates(ty::GenericPredicates {
parent: None, parent: None,
predicates: tcx.bound_explicit_item_bounds(def_id).skip_binder(), predicates: tcx.explicit_item_bounds(def_id).skip_binder(),
})?; })?;
} }
} }
@ -1784,10 +1784,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
fn bounds(&mut self) -> &mut Self { fn bounds(&mut self) -> &mut Self {
self.visit_predicates(ty::GenericPredicates { self.visit_predicates(ty::GenericPredicates {
parent: None, parent: None,
predicates: self predicates: self.tcx.explicit_item_bounds(self.item_def_id).skip_binder(),
.tcx
.bound_explicit_item_bounds(self.item_def_id.to_def_id())
.skip_binder(),
}); });
self self
} }

View file

@ -297,7 +297,7 @@ fn bounds_reference_self(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span
tcx.associated_items(trait_def_id) tcx.associated_items(trait_def_id)
.in_definition_order() .in_definition_order()
.filter(|item| item.kind == ty::AssocKind::Type) .filter(|item| item.kind == ty::AssocKind::Type)
.flat_map(|item| tcx.bound_explicit_item_bounds(item.def_id).transpose_iter()) .flat_map(|item| tcx.explicit_item_bounds(item.def_id).transpose_iter())
.map(|bound| bound.map_bound(|b| *b).subst_identity()) .map(|bound| bound.map_bound(|b| *b).subst_identity())
.filter_map(|pred_span| predicate_references_self(tcx, pred_span)) .filter_map(|pred_span| predicate_references_self(tcx, pred_span))
.collect() .collect()

View file

@ -50,7 +50,7 @@ impl<'tcx> RustIrDatabase<'tcx> {
where where
ty::Predicate<'tcx>: LowerInto<'tcx, std::option::Option<T>>, ty::Predicate<'tcx>: LowerInto<'tcx, std::option::Option<T>>,
{ {
let bounds = self.interner.tcx.bound_explicit_item_bounds(def_id); let bounds = self.interner.tcx.explicit_item_bounds(def_id);
bounds bounds
.0 .0
.iter() .iter()
@ -506,7 +506,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
let identity_substs = InternalSubsts::identity_for_item(self.interner.tcx, opaque_ty_id.0); let identity_substs = InternalSubsts::identity_for_item(self.interner.tcx, opaque_ty_id.0);
let explicit_item_bounds = self.interner.tcx.bound_explicit_item_bounds(opaque_ty_id.0); let explicit_item_bounds = self.interner.tcx.explicit_item_bounds(opaque_ty_id.0);
let bounds = let bounds =
explicit_item_bounds explicit_item_bounds
.0 .0

View file

@ -421,7 +421,7 @@ fn clean_projection<'tcx>(
if cx.tcx.is_impl_trait_in_trait(ty.skip_binder().def_id) { if cx.tcx.is_impl_trait_in_trait(ty.skip_binder().def_id) {
let bounds = cx let bounds = cx
.tcx .tcx
.bound_explicit_item_bounds(ty.skip_binder().def_id) .explicit_item_bounds(ty.skip_binder().def_id)
.subst_iter_copied(cx.tcx, ty.skip_binder().substs) .subst_iter_copied(cx.tcx, ty.skip_binder().substs)
.map(|(pred, _)| pred) .map(|(pred, _)| pred)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -1316,7 +1316,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
if let ty::TraitContainer = assoc_item.container { if let ty::TraitContainer = assoc_item.container {
let bounds = tcx let bounds = tcx
.bound_explicit_item_bounds(assoc_item.def_id) .explicit_item_bounds(assoc_item.def_id)
.transpose_iter() .transpose_iter()
.map(|bound| bound.map_bound(|b| *b).subst_identity()); .map(|bound| bound.map_bound(|b| *b).subst_identity());
let predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates; let predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates;
@ -1847,7 +1847,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
// by looking up the bounds associated with the def_id. // by looking up the bounds associated with the def_id.
let bounds = cx let bounds = cx
.tcx .tcx
.bound_explicit_item_bounds(def_id) .explicit_item_bounds(def_id)
.subst_iter_copied(cx.tcx, substs) .subst_iter_copied(cx.tcx, substs)
.map(|(bound, _)| bound) .map(|(bound, _)| bound)
.collect::<Vec<_>>(); .collect::<Vec<_>>();

View file

@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
} }
let ret_ty = return_ty(cx, cx.tcx.hir().local_def_id_to_hir_id(fn_def_id).expect_owner()); let ret_ty = return_ty(cx, cx.tcx.hir().local_def_id_to_hir_id(fn_def_id).expect_owner());
if let ty::Alias(ty::Opaque, AliasTy { def_id, substs, .. }) = *ret_ty.kind() { if let ty::Alias(ty::Opaque, AliasTy { def_id, substs, .. }) = *ret_ty.kind() {
let preds = cx.tcx.bound_explicit_item_bounds(def_id); let preds = cx.tcx.explicit_item_bounds(def_id);
let mut is_future = false; let mut is_future = false;
for (p, _span) in preds.subst_iter_copied(cx.tcx, substs) { for (p, _span) in preds.subst_iter_copied(cx.tcx, substs) {
if let Some(trait_pred) = p.to_opt_poly_trait_pred() { if let Some(trait_pred) = p.to_opt_poly_trait_pred() {

View file

@ -90,7 +90,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
return false; return false;
} }
for bound in cx.tcx.bound_explicit_item_bounds(def_id).transpose_iter() { for bound in cx.tcx.explicit_item_bounds(def_id).transpose_iter() {
let (predicate, _span) = bound.map_bound(|b| *b).subst_identity(); let (predicate, _span) = bound.map_bound(|b| *b).subst_identity();
match predicate.kind().skip_binder() { match predicate.kind().skip_binder() {
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through // For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
@ -268,7 +268,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
}, },
ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)), ty::Tuple(substs) => substs.iter().any(|ty| is_must_use_ty(cx, ty)),
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => { ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
for (predicate, _) in cx.tcx.bound_explicit_item_bounds(*def_id).skip_binder() { for (predicate, _) in cx.tcx.explicit_item_bounds(def_id).skip_binder() {
if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() { if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() {
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) { if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
return true; return true;
@ -744,7 +744,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option
for (pred, _) in cx for (pred, _) in cx
.tcx .tcx
.bound_explicit_item_bounds(ty.def_id) .explicit_item_bounds(ty.def_id)
.subst_iter_copied(cx.tcx, ty.substs) .subst_iter_copied(cx.tcx, ty.substs)
{ {
match pred.kind().skip_binder() { match pred.kind().skip_binder() {