Make item self/non-self bound naming less whack
This commit is contained in:
parent
3f8ce7c973
commit
009d68740f
19 changed files with 91 additions and 100 deletions
|
@ -457,7 +457,7 @@ fn fn_sig_suggestion<'tcx>(
|
|||
|
||||
let asyncness = if tcx.asyncness(assoc.def_id).is_async() {
|
||||
output = if let ty::Alias(_, alias_ty) = *output.kind() {
|
||||
tcx.explicit_item_super_predicates(alias_ty.def_id)
|
||||
tcx.explicit_item_self_bounds(alias_ty.def_id)
|
||||
.iter_instantiated_copied(tcx, alias_ty.args)
|
||||
.find_map(|(bound, _)| {
|
||||
bound.as_projection_clause()?.no_bound_vars()?.term.as_type()
|
||||
|
|
|
@ -65,9 +65,9 @@ pub fn provide(providers: &mut Providers) {
|
|||
type_alias_is_lazy: type_of::type_alias_is_lazy,
|
||||
item_bounds: item_bounds::item_bounds,
|
||||
explicit_item_bounds: item_bounds::explicit_item_bounds,
|
||||
item_super_predicates: item_bounds::item_super_predicates,
|
||||
explicit_item_super_predicates: item_bounds::explicit_item_super_predicates,
|
||||
item_non_self_assumptions: item_bounds::item_non_self_assumptions,
|
||||
item_self_bounds: item_bounds::item_self_bounds,
|
||||
explicit_item_self_bounds: item_bounds::explicit_item_self_bounds,
|
||||
item_non_self_bounds: item_bounds::item_non_self_bounds,
|
||||
impl_super_outlives: item_bounds::impl_super_outlives,
|
||||
generics_of: generics_of::generics_of,
|
||||
predicates_of: predicates_of::predicates_of,
|
||||
|
@ -328,9 +328,9 @@ impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
|||
self.tcx.ensure().generics_of(def_id);
|
||||
self.tcx.ensure().predicates_of(def_id);
|
||||
self.tcx.ensure().explicit_item_bounds(def_id);
|
||||
self.tcx.ensure().explicit_item_super_predicates(def_id);
|
||||
self.tcx.ensure().explicit_item_self_bounds(def_id);
|
||||
self.tcx.ensure().item_bounds(def_id);
|
||||
self.tcx.ensure().item_super_predicates(def_id);
|
||||
self.tcx.ensure().item_self_bounds(def_id);
|
||||
if self.tcx.is_conditionally_const(def_id) {
|
||||
self.tcx.ensure().explicit_implied_const_bounds(def_id);
|
||||
self.tcx.ensure().const_conditions(def_id);
|
||||
|
@ -822,7 +822,7 @@ fn lower_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
|
|||
|
||||
hir::TraitItemKind::Type(_, Some(_)) => {
|
||||
tcx.ensure().item_bounds(def_id);
|
||||
tcx.ensure().item_super_predicates(def_id);
|
||||
tcx.ensure().item_self_bounds(def_id);
|
||||
tcx.ensure().type_of(def_id);
|
||||
// Account for `type T = _;`.
|
||||
let mut visitor = HirPlaceholderCollector::default();
|
||||
|
@ -839,7 +839,7 @@ fn lower_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
|
|||
|
||||
hir::TraitItemKind::Type(_, None) => {
|
||||
tcx.ensure().item_bounds(def_id);
|
||||
tcx.ensure().item_super_predicates(def_id);
|
||||
tcx.ensure().item_self_bounds(def_id);
|
||||
// #74612: Visit and try to find bad placeholders
|
||||
// even if there is no concrete type.
|
||||
let mut visitor = HirPlaceholderCollector::default();
|
||||
|
|
|
@ -350,7 +350,7 @@ pub(super) fn explicit_item_bounds(
|
|||
explicit_item_bounds_with_filter(tcx, def_id, PredicateFilter::All)
|
||||
}
|
||||
|
||||
pub(super) fn explicit_item_super_predicates(
|
||||
pub(super) fn explicit_item_self_bounds(
|
||||
tcx: TyCtxt<'_>,
|
||||
def_id: LocalDefId,
|
||||
) -> ty::EarlyBinder<'_, &'_ [(ty::Clause<'_>, Span)]> {
|
||||
|
@ -434,11 +434,11 @@ pub(super) fn item_bounds(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<'_,
|
|||
})
|
||||
}
|
||||
|
||||
pub(super) fn item_super_predicates(
|
||||
pub(super) fn item_self_bounds(
|
||||
tcx: TyCtxt<'_>,
|
||||
def_id: DefId,
|
||||
) -> ty::EarlyBinder<'_, ty::Clauses<'_>> {
|
||||
tcx.explicit_item_super_predicates(def_id).map_bound(|bounds| {
|
||||
tcx.explicit_item_self_bounds(def_id).map_bound(|bounds| {
|
||||
tcx.mk_clauses_from_iter(
|
||||
util::elaborate(tcx, bounds.iter().map(|&(bound, _span)| bound)).filter_only_self(),
|
||||
)
|
||||
|
@ -447,13 +447,12 @@ pub(super) fn item_super_predicates(
|
|||
|
||||
/// This exists as an optimization to compute only the item bounds of the item
|
||||
/// that are not `Self` bounds.
|
||||
pub(super) fn item_non_self_assumptions(
|
||||
pub(super) fn item_non_self_bounds(
|
||||
tcx: TyCtxt<'_>,
|
||||
def_id: DefId,
|
||||
) -> ty::EarlyBinder<'_, ty::Clauses<'_>> {
|
||||
let all_bounds: FxIndexSet<_> = tcx.item_bounds(def_id).skip_binder().iter().collect();
|
||||
let own_bounds: FxIndexSet<_> =
|
||||
tcx.item_super_predicates(def_id).skip_binder().iter().collect();
|
||||
let own_bounds: FxIndexSet<_> = tcx.item_self_bounds(def_id).skip_binder().iter().collect();
|
||||
if all_bounds.len() == own_bounds.len() {
|
||||
ty::EarlyBinder::bind(ty::ListWithCachedTypeInfo::empty())
|
||||
} else {
|
||||
|
|
|
@ -308,7 +308,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
expected_ty,
|
||||
closure_kind,
|
||||
self.tcx
|
||||
.explicit_item_super_predicates(def_id)
|
||||
.explicit_item_self_bounds(def_id)
|
||||
.iter_instantiated_copied(self.tcx, args)
|
||||
.map(|(c, s)| (c.as_predicate(), s)),
|
||||
),
|
||||
|
@ -981,7 +981,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => self
|
||||
.tcx
|
||||
.explicit_item_super_predicates(def_id)
|
||||
.explicit_item_self_bounds(def_id)
|
||||
.iter_instantiated_copied(self.tcx, args)
|
||||
.find_map(|(p, s)| get_future_output(p.as_predicate(), s))?,
|
||||
ty::Error(_) => return Some(ret_ty),
|
||||
|
|
|
@ -1847,30 +1847,26 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
|||
fcx.probe(|_| {
|
||||
let ocx = ObligationCtxt::new(fcx);
|
||||
ocx.register_obligations(
|
||||
fcx.tcx.item_super_predicates(rpit_def_id).iter_identity().filter_map(
|
||||
|clause| {
|
||||
let predicate = clause
|
||||
.kind()
|
||||
.map_bound(|clause| match clause {
|
||||
ty::ClauseKind::Trait(trait_pred) => Some(
|
||||
ty::ClauseKind::Trait(trait_pred.with_self_ty(fcx.tcx, ty)),
|
||||
),
|
||||
ty::ClauseKind::Projection(proj_pred) => {
|
||||
Some(ty::ClauseKind::Projection(
|
||||
proj_pred.with_self_ty(fcx.tcx, ty),
|
||||
))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.transpose()?;
|
||||
Some(Obligation::new(
|
||||
fcx.tcx,
|
||||
ObligationCause::dummy(),
|
||||
fcx.param_env,
|
||||
predicate,
|
||||
))
|
||||
},
|
||||
),
|
||||
fcx.tcx.item_self_bounds(rpit_def_id).iter_identity().filter_map(|clause| {
|
||||
let predicate = clause
|
||||
.kind()
|
||||
.map_bound(|clause| match clause {
|
||||
ty::ClauseKind::Trait(trait_pred) => Some(ty::ClauseKind::Trait(
|
||||
trait_pred.with_self_ty(fcx.tcx, ty),
|
||||
)),
|
||||
ty::ClauseKind::Projection(proj_pred) => Some(
|
||||
ty::ClauseKind::Projection(proj_pred.with_self_ty(fcx.tcx, ty)),
|
||||
),
|
||||
_ => None,
|
||||
})
|
||||
.transpose()?;
|
||||
Some(Obligation::new(
|
||||
fcx.tcx,
|
||||
ObligationCause::dummy(),
|
||||
fcx.param_env,
|
||||
predicate,
|
||||
))
|
||||
}),
|
||||
);
|
||||
ocx.select_where_possible().is_empty()
|
||||
})
|
||||
|
|
|
@ -281,7 +281,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
|
|||
alias_ty: ty::AliasTy<'tcx>,
|
||||
) -> impl Iterator<Item = ty::Region<'tcx>> {
|
||||
let tcx = self.tcx;
|
||||
let bounds = tcx.item_super_predicates(alias_ty.def_id);
|
||||
let bounds = tcx.item_self_bounds(alias_ty.def_id);
|
||||
trace!("{:#?}", bounds.skip_binder());
|
||||
bounds
|
||||
.iter_instantiated(tcx, alias_ty.args)
|
||||
|
|
|
@ -289,25 +289,22 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
|||
}
|
||||
ty::Adt(def, _) => is_def_must_use(cx, def.did(), span),
|
||||
ty::Alias(ty::Opaque | ty::Projection, ty::AliasTy { def_id: def, .. }) => {
|
||||
elaborate(
|
||||
cx.tcx,
|
||||
cx.tcx.explicit_item_super_predicates(def).iter_identity_copied(),
|
||||
)
|
||||
// We only care about self bounds for the impl-trait
|
||||
.filter_only_self()
|
||||
.find_map(|(pred, _span)| {
|
||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||
if let ty::ClauseKind::Trait(ref poly_trait_predicate) =
|
||||
pred.kind().skip_binder()
|
||||
{
|
||||
let def_id = poly_trait_predicate.trait_ref.def_id;
|
||||
elaborate(cx.tcx, cx.tcx.explicit_item_self_bounds(def).iter_identity_copied())
|
||||
// We only care about self bounds for the impl-trait
|
||||
.filter_only_self()
|
||||
.find_map(|(pred, _span)| {
|
||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||
if let ty::ClauseKind::Trait(ref poly_trait_predicate) =
|
||||
pred.kind().skip_binder()
|
||||
{
|
||||
let def_id = poly_trait_predicate.trait_ref.def_id;
|
||||
|
||||
is_def_must_use(cx, def_id, span)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.map(|inner| MustUsePath::Opaque(Box::new(inner)))
|
||||
is_def_must_use(cx, def_id, span)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.map(|inner| MustUsePath::Opaque(Box::new(inner)))
|
||||
}
|
||||
ty::Dynamic(binders, _, _) => binders.iter().find_map(|predicate| {
|
||||
if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate.skip_binder()
|
||||
|
|
|
@ -241,7 +241,7 @@ impl IntoArgs for (CrateNum, SimplifiedType) {
|
|||
|
||||
provide! { tcx, def_id, other, cdata,
|
||||
explicit_item_bounds => { table_defaulted_array }
|
||||
explicit_item_super_predicates => { table_defaulted_array }
|
||||
explicit_item_self_bounds => { table_defaulted_array }
|
||||
explicit_predicates_of => { table }
|
||||
generics_of => { table }
|
||||
inferred_outlives_of => { table_defaulted_array }
|
||||
|
|
|
@ -1554,7 +1554,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
}
|
||||
if let DefKind::OpaqueTy = def_kind {
|
||||
self.encode_explicit_item_bounds(def_id);
|
||||
self.encode_explicit_item_super_predicates(def_id);
|
||||
self.encode_explicit_item_self_bounds(def_id);
|
||||
record!(self.tables.opaque_ty_origin[def_id] <- self.tcx.opaque_ty_origin(def_id));
|
||||
self.encode_precise_capturing_args(def_id);
|
||||
if tcx.is_conditionally_const(def_id) {
|
||||
|
@ -1667,10 +1667,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
record_defaulted_array!(self.tables.explicit_item_bounds[def_id] <- bounds);
|
||||
}
|
||||
|
||||
fn encode_explicit_item_super_predicates(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_explicit_item_super_predicates({:?})", def_id);
|
||||
let bounds = self.tcx.explicit_item_super_predicates(def_id).skip_binder();
|
||||
record_defaulted_array!(self.tables.explicit_item_super_predicates[def_id] <- bounds);
|
||||
fn encode_explicit_item_self_bounds(&mut self, def_id: DefId) {
|
||||
debug!("EncodeContext::encode_explicit_item_self_bounds({:?})", def_id);
|
||||
let bounds = self.tcx.explicit_item_self_bounds(def_id).skip_binder();
|
||||
record_defaulted_array!(self.tables.explicit_item_self_bounds[def_id] <- bounds);
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
|
@ -1685,7 +1685,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
AssocItemContainer::Trait => {
|
||||
if let ty::AssocKind::Type = item.kind {
|
||||
self.encode_explicit_item_bounds(def_id);
|
||||
self.encode_explicit_item_super_predicates(def_id);
|
||||
self.encode_explicit_item_self_bounds(def_id);
|
||||
if tcx.is_conditionally_const(def_id) {
|
||||
record_defaulted_array!(self.tables.explicit_implied_const_bounds[def_id]
|
||||
<- self.tcx.explicit_implied_const_bounds(def_id).skip_binder());
|
||||
|
|
|
@ -386,7 +386,7 @@ define_tables! {
|
|||
// corresponding DefPathHash.
|
||||
def_path_hashes: Table<DefIndex, u64>,
|
||||
explicit_item_bounds: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
|
||||
explicit_item_super_predicates: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
|
||||
explicit_item_self_bounds: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
|
||||
inferred_outlives_of: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
|
||||
explicit_super_predicates_of: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
|
||||
explicit_implied_predicates_of: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
|
||||
|
|
|
@ -393,7 +393,7 @@ rustc_queries! {
|
|||
/// like closure signature deduction.
|
||||
///
|
||||
/// [explicit item bounds]: Self::explicit_item_bounds
|
||||
query explicit_item_super_predicates(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
|
||||
query explicit_item_self_bounds(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
|
||||
desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
|
||||
cache_on_disk_if { key.is_local() }
|
||||
separate_provide_extern
|
||||
|
@ -427,11 +427,11 @@ rustc_queries! {
|
|||
desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
|
||||
}
|
||||
|
||||
query item_super_predicates(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> {
|
||||
query item_self_bounds(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> {
|
||||
desc { |tcx| "elaborating item assumptions for `{}`", tcx.def_path_str(key) }
|
||||
}
|
||||
|
||||
query item_non_self_assumptions(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> {
|
||||
query item_non_self_bounds(key: DefId) -> ty::EarlyBinder<'tcx, ty::Clauses<'tcx>> {
|
||||
desc { |tcx| "elaborating item assumptions for `{}`", tcx.def_path_str(key) }
|
||||
}
|
||||
|
||||
|
|
|
@ -349,14 +349,14 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||
self,
|
||||
def_id: DefId,
|
||||
) -> ty::EarlyBinder<'tcx, impl IntoIterator<Item = ty::Clause<'tcx>>> {
|
||||
self.item_super_predicates(def_id).map_bound(IntoIterator::into_iter)
|
||||
self.item_self_bounds(def_id).map_bound(IntoIterator::into_iter)
|
||||
}
|
||||
|
||||
fn item_non_self_bounds(
|
||||
self,
|
||||
def_id: DefId,
|
||||
) -> ty::EarlyBinder<'tcx, impl IntoIterator<Item = ty::Clause<'tcx>>> {
|
||||
self.item_non_self_assumptions(def_id).map_bound(IntoIterator::into_iter)
|
||||
self.item_non_self_bounds(def_id).map_bound(IntoIterator::into_iter)
|
||||
}
|
||||
|
||||
fn predicates_of(
|
||||
|
@ -2591,7 +2591,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false };
|
||||
let future_trait = self.require_lang_item(LangItem::Future, None);
|
||||
|
||||
self.explicit_item_super_predicates(def_id).skip_binder().iter().any(|&(predicate, _)| {
|
||||
self.explicit_item_self_bounds(def_id).skip_binder().iter().any(|&(predicate, _)| {
|
||||
let ty::ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder() else {
|
||||
return false;
|
||||
};
|
||||
|
|
|
@ -64,7 +64,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>> {
|
||||
let mut bounds: Vec<_> = self
|
||||
.item_super_predicates(def_id)
|
||||
.item_self_bounds(def_id)
|
||||
.iter_instantiated(self, args)
|
||||
.filter_map(|clause| {
|
||||
clause
|
||||
|
|
|
@ -196,7 +196,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
let item_def_id = self.tcx.associated_item_def_ids(future_trait)[0];
|
||||
|
||||
self.tcx
|
||||
.explicit_item_super_predicates(def_id)
|
||||
.explicit_item_self_bounds(def_id)
|
||||
.iter_instantiated_copied(self.tcx, args)
|
||||
.find_map(|(predicate, _)| {
|
||||
predicate
|
||||
|
|
|
@ -293,7 +293,7 @@ impl<T> Trait<T> for X {
|
|||
(ty::Dynamic(t, _, ty::DynKind::Dyn), ty::Alias(ty::Opaque, alias))
|
||||
if let Some(def_id) = t.principal_def_id()
|
||||
&& tcx
|
||||
.explicit_item_super_predicates(alias.def_id)
|
||||
.explicit_item_self_bounds(alias.def_id)
|
||||
.skip_binder()
|
||||
.iter()
|
||||
.any(|(pred, _span)| match pred.kind().skip_binder() {
|
||||
|
@ -422,7 +422,7 @@ impl<T> Trait<T> for X {
|
|||
ty::Alias(..) => values.expected,
|
||||
_ => values.found,
|
||||
};
|
||||
let preds = tcx.explicit_item_super_predicates(opaque_ty.def_id);
|
||||
let preds = tcx.explicit_item_self_bounds(opaque_ty.def_id);
|
||||
for (pred, _span) in preds.skip_binder() {
|
||||
let ty::ClauseKind::Trait(trait_predicate) = pred.kind().skip_binder()
|
||||
else {
|
||||
|
|
|
@ -1087,28 +1087,27 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
sig_parts.map_bound(|sig| sig.tupled_inputs_ty.tuple_fields().as_slice()),
|
||||
))
|
||||
}
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => self
|
||||
.tcx
|
||||
.item_super_predicates(def_id)
|
||||
.instantiate(self.tcx, args)
|
||||
.iter()
|
||||
.find_map(|pred| {
|
||||
if let ty::ClauseKind::Projection(proj) = pred.kind().skip_binder()
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {
|
||||
self.tcx.item_self_bounds(def_id).instantiate(self.tcx, args).iter().find_map(
|
||||
|pred| {
|
||||
if let ty::ClauseKind::Projection(proj) = pred.kind().skip_binder()
|
||||
&& self
|
||||
.tcx
|
||||
.is_lang_item(proj.projection_term.def_id, LangItem::FnOnceOutput)
|
||||
// args tuple will always be args[1]
|
||||
&& let ty::Tuple(args) = proj.projection_term.args.type_at(1).kind()
|
||||
{
|
||||
Some((
|
||||
DefIdOrName::DefId(def_id),
|
||||
pred.kind().rebind(proj.term.expect_type()),
|
||||
pred.kind().rebind(args.as_slice()),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}),
|
||||
{
|
||||
Some((
|
||||
DefIdOrName::DefId(def_id),
|
||||
pred.kind().rebind(proj.term.expect_type()),
|
||||
pred.kind().rebind(args.as_slice()),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
ty::Dynamic(data, _, ty::Dyn) => data.iter().find_map(|pred| {
|
||||
if let ty::ExistentialPredicate::Projection(proj) = pred.skip_binder()
|
||||
&& self.tcx.is_lang_item(proj.def_id, LangItem::FnOnceOutput)
|
||||
|
|
|
@ -1620,9 +1620,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// projections, we will never be able to equate, e.g. `<T as Tr>::A`
|
||||
// with `<<T as Tr>::A as Tr>::A`.
|
||||
let relevant_bounds = if in_parent_alias_type {
|
||||
self.tcx().item_non_self_assumptions(alias_ty.def_id)
|
||||
self.tcx().item_non_self_bounds(alias_ty.def_id)
|
||||
} else {
|
||||
self.tcx().item_super_predicates(alias_ty.def_id)
|
||||
self.tcx().item_self_bounds(alias_ty.def_id)
|
||||
};
|
||||
|
||||
for bound in relevant_bounds.instantiate(self.tcx(), alias_ty.args) {
|
||||
|
|
|
@ -79,7 +79,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
|||
&& let Some(future_trait) = cx.tcx.lang_items().future_trait()
|
||||
&& let Some(send_trait) = cx.tcx.get_diagnostic_item(sym::Send)
|
||||
{
|
||||
let preds = cx.tcx.explicit_item_super_predicates(def_id);
|
||||
let preds = cx.tcx.explicit_item_self_bounds(def_id);
|
||||
let is_future = preds.iter_instantiated_copied(cx.tcx, args).any(|(p, _)| {
|
||||
p.as_trait_clause()
|
||||
.is_some_and(|trait_pred| trait_pred.skip_binder().trait_ref.def_id == future_trait)
|
||||
|
|
|
@ -96,7 +96,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
|
|||
return false;
|
||||
}
|
||||
|
||||
for (predicate, _span) in cx.tcx.explicit_item_super_predicates(def_id).iter_identity_copied() {
|
||||
for (predicate, _span) in cx.tcx.explicit_item_self_bounds(def_id).iter_identity_copied() {
|
||||
match predicate.kind().skip_binder() {
|
||||
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
|
||||
// and check substitutions to find `U`.
|
||||
|
@ -322,7 +322,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
|
|||
},
|
||||
ty::Tuple(args) => args.iter().any(|ty| is_must_use_ty(cx, ty)),
|
||||
ty::Alias(ty::Opaque, AliasTy { def_id, .. }) => {
|
||||
for (predicate, _) in cx.tcx.explicit_item_super_predicates(def_id).skip_binder() {
|
||||
for (predicate, _) in cx.tcx.explicit_item_self_bounds(def_id).skip_binder() {
|
||||
if let ty::ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder() {
|
||||
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
|
||||
return true;
|
||||
|
@ -712,7 +712,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
|
|||
ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) => sig_from_bounds(
|
||||
cx,
|
||||
ty,
|
||||
cx.tcx.item_super_predicates(def_id).iter_instantiated(cx.tcx, args),
|
||||
cx.tcx.item_self_bounds(def_id).iter_instantiated(cx.tcx, args),
|
||||
cx.tcx.opt_parent(def_id),
|
||||
),
|
||||
ty::FnPtr(sig_tys, hdr) => Some(ExprFnSig::Sig(sig_tys.with(hdr), None)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue