1
Fork 0

Auto merge of #125006 - spastorino:generics-is-empty, r=compiler-errors

Add and use generics.is_empty() and generics.is_own_empty, rather than using generics' attributes

r? `@compiler-errors`

Related to #123929
This commit is contained in:
bors 2024-05-19 19:22:57 +00:00
commit 1d1283ed09
18 changed files with 25 additions and 17 deletions

View file

@ -398,7 +398,7 @@ pub fn object_safety_violations_for_assoc_item(
// Associated types can only be object safe if they have `Self: Sized` bounds.
ty::AssocKind::Type => {
if !tcx.features().generic_associated_types_extended
&& !tcx.generics_of(item.def_id).own_params.is_empty()
&& !tcx.generics_of(item.def_id).is_own_empty()
&& !item.is_impl_trait_in_trait()
{
vec![ObjectSafetyViolation::GAT(item.name, item.ident(tcx).span)]

View file

@ -619,7 +619,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// higher-ranked things.
// Prevent, e.g., `dyn Iterator<Item = str>`.
for bound in self.tcx().item_bounds(assoc_type).transpose_iter() {
let arg_bound = if defs.count() == 0 {
let arg_bound = if defs.is_empty() {
bound.instantiate(tcx, trait_predicate.trait_ref.args)
} else {
let mut args = smallvec::SmallVec::with_capacity(defs.count());

View file

@ -1781,7 +1781,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// FIXME(generic-associated-types): This only detects one layer of inference,
// which is probably not what we actually want, but fixing it causes some ambiguity:
// <https://github.com/rust-lang/rust/issues/125196>.
if !generics.own_params.is_empty()
if !generics.is_own_empty()
&& obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
p.has_non_region_infer()
&& match p.unpack() {