Skip to content

Conversation

@cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Oct 15, 2025

ast::TyAliasWhereClauses is a tentative to avoid forgetting predicates when manipulating the AST.
It is incompatible with cfg attributes on where clauses.

This PR uses a regular WhereClause for the "second" clause.

Fixes #138010
cc #138037

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 15, 2025
@rustbot

This comment was marked as outdated.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@fmease fmease Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use the more minimal reproducers, #138010 (comment) and/or #138010 (comment) which are less obfuscated. Moreover, #138010 (comment) wouldn't require any extra unstable features.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my comment above I meant removing any of the redundant and distracting bits of cfg-attr-issue-138010-1.rs given it's a fuzzer-produced file (extra functions, check-cfg warnings, a useless let binding, useless (): bounds, etc.).

It can be distilled to:

#![feature(lazy_type_alias)]
#![expect(incomplete_features)]

type Type
where
    #[cfg(false)]
    String: Copy,
= ();

fn main() {}

… which just shows that it's just cfg-attr-issue-138010-2.rs.

So could you please throw out the *-1.rs or replace *-1.rs with the MCVE above and remove the *-2.rs (I don't really care about the #[cfg(true)] case but whatever).

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 15, 2025
@fmease fmease assigned fmease and unassigned jdonszelmann Oct 15, 2025
@jackh726
Copy link
Member

IIRC adding the purpose of adding this type was never to avoid allocating vecs, but rather to maintain the two separate Span locations and the predicates derived for them, and also unify the handling of the where clauses (with the idea that we may remove the ability to remove the before where clauses at some point, I also don't remember if there was some specific motivating reason for this or if it was just a general decision).

I'm a little surprised we don't regress any test outputs, but I guess all the info is still there, but now less well-defined.

I have mixed feelings here. I worry that this could lead to places checking the where clauses in generics but not in after_where_clauses, that was perhaps the motivating reason for this. Them being in the same place means that nobody can forget about them anywhere.

@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2025

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added T-clippy Relevant to the Clippy team. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. labels Oct 15, 2025
@cjgillot
Copy link
Contributor Author

IIRC adding the purpose of adding this type was never to avoid allocating vecs, but rather to maintain the two separate Span locations and the predicates derived for them, and also unify the handling of the where clauses (with the idea that we may remove the ability to remove the before where clauses at some point, I also don't remember if there was some specific motivating reason for this or if it was just a general decision).

I'm a little surprised we don't regress any test outputs, but I guess all the info is still there, but now less well-defined.

I'm not sure about the "less well-defined". In the current state, we have the information about the "before" span twice. Here we have everything once.

I have mixed feelings here. I worry that this could lead to places checking the where clauses in generics but not in after_where_clauses, that was perhaps the motivating reason for this. Them being in the same place means that nobody can forget about them anywhere.

This is mitigated by lowering. Most of the places where we manipulate predicates are on HIR, which does merge the lists. On the other hand, AST needs to be as close to the concrete syntax as possible for macro expansion.

@rustbot

This comment has been minimized.

@cjgillot cjgillot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 16, 2025
@jackh726
Copy link
Member

IIRC adding the purpose of adding this type was never to avoid allocating vecs, but rather to maintain the two separate Span locations and the predicates derived for them, and also unify the handling of the where clauses (with the idea that we may remove the ability to remove the before where clauses at some point, I also don't remember if there was some specific motivating reason for this or if it was just a general decision).
I'm a little surprised we don't regress any test outputs, but I guess all the info is still there, but now less well-defined.

I'm not sure about the "less well-defined". In the current state, we have the information about the "before" span twice. Here we have everything once.

Yes, "less well-defined" is perhaps not the right way to say this. What I mostly trying to say is that I could have imagined that it would have been easy (and could be easy in the future) to miss a case where we need to do something with both the where clauses in generics and after_where_clauses (whereas prior to this PR, it's not an "extra" thing you have to think about)

I have mixed feelings here. I worry that this could lead to places checking the where clauses in generics but not in after_where_clauses, that was perhaps the motivating reason for this. Them being in the same place means that nobody can forget about them anywhere.

This is mitigated by lowering. Most of the places where we manipulate predicates are on HIR, which does merge the lists. On the other hand, AST needs to be as close to the concrete syntax as possible for macro expansion.

Okay, good enough for me, I guess.

@rustbot

This comment has been minimized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my comment above I meant removing any of the redundant and distracting bits of cfg-attr-issue-138010-1.rs given it's a fuzzer-produced file (extra functions, check-cfg warnings, a useless let binding, useless (): bounds, etc.).

It can be distilled to:

#![feature(lazy_type_alias)]
#![expect(incomplete_features)]

type Type
where
    #[cfg(false)]
    String: Copy,
= ();

fn main() {}

… which just shows that it's just cfg-attr-issue-138010-2.rs.

So could you please throw out the *-1.rs or replace *-1.rs with the MCVE above and remove the *-2.rs (I don't really care about the #[cfg(true)] case but whatever).

@fmease
Copy link
Member

fmease commented Oct 22, 2025

Thanks! Some final nits (+ optional squash), then r=me

@bors rollup

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@cjgillot
Copy link
Contributor Author

@bors r=fmease

@bors
Copy link
Collaborator

bors commented Oct 23, 2025

📌 Commit 15c91bf has been approved by fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 23, 2025
bors added a commit that referenced this pull request Oct 23, 2025
Rollup of 3 pull requests

Successful merges:

 - #134316 (Add `String::replace_first` and `String::replace_last`)
 - #147713 (Retire ast::TyAliasWhereClauses.)
 - #148011 (Revert constification of `AsRef for Cow` due to inference failure )

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0185feb into rust-lang:master Oct 23, 2025
11 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 23, 2025
rust-timer added a commit that referenced this pull request Oct 23, 2025
Rollup merge of #147713 - cjgillot:where-cfg, r=fmease

Retire ast::TyAliasWhereClauses.

`ast::TyAliasWhereClauses` is a tentative to avoid forgetting predicates when manipulating the AST.
It is incompatible with `cfg` attributes on where clauses.

This PR uses a regular `WhereClause` for the "second" clause.

Fixes #138010
cc #138037
@cjgillot cjgillot deleted the where-cfg branch October 24, 2025 02:41
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Oct 24, 2025
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#134316 (Add `String::replace_first` and `String::replace_last`)
 - rust-lang/rust#147713 (Retire ast::TyAliasWhereClauses.)
 - rust-lang/rust#148011 (Revert constification of `AsRef for Cow` due to inference failure )

r? `@ghost`
`@rustbot` modify labels: rollup
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Oct 27, 2025
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#134316 (Add `String::replace_first` and `String::replace_last`)
 - rust-lang/rust#147713 (Retire ast::TyAliasWhereClauses.)
 - rust-lang/rust#148011 (Revert constification of `AsRef for Cow` due to inference failure )

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: mid > len on leading assoc ty / lazy type alias where clause with attributes

7 participants