Fix split index calculation in check_type_alias_where_clause_location
by stuuupidcat · Pull Request #138037 · rust-lang/rust (original) (raw)
Filtering things which have attributes applied to them isn't really correct because it's not necessarily the case that all cfg
d where clauses will be removed during macro expansion, e.g.
#![feature(where_clause_attrs, cfg_boolean_literals, lazy_type_alias)] #![expect(incomplete_features)]
struct Foo; trait Trait {}
impl Trait for Foo {}
type MixedWhereBounds where #[cfg(true)] Foo: Trait, = Foo where (): Sized;
Here we have a where clause before the =
that has an attribute applied to it, yet the where clause will still be present after macro expansion.
If you run the compiler on this example with your changes, and then remove the cfg
, you'll get different diagnostics output even though post-expansion it'll be the same set of where clauses. That's caused by this before_with_attr_count
being 1
and then when we split the where clauses into before/after you wind up splitting at 0
so both clauses end up in the "after" bucket.
Can you add both version as a test (with/without cfg(true)
)?