Skip to content

Fix where clause parsing of type aliases & const items - #165256

Open
fmease wants to merge 6 commits into
rust-lang:mainfrom
fmease:parser-where-clauses-fixes
Open

fmease wants to merge 6 commits into
rust-lang:mainfrom
fmease:parser-where-clauses-fixes

Conversation

@fmease

@fmease fmease commented Oct 31, 2026 •

Copy link
Copy Markdown
Member
  1. Don't artificially reject duplicate (non-empty) where clauses on bodiless type aliases / associated types.
  2. Reject (literally) where where (i.e., duplicate empty where clauses) on const items (unstable feature generic_const_items). See commit for details.
  3. Tiny compiler & test cleanups that were necessary to soundly navigate these seas

Best reviewed commit by commit.

(No LLM was or will be used by me during the entire creation process of this PR)

@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 31, 2026
@rustbot

rustbot commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

r? @beetrees

rustbot has assigned @beetrees.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 22 candidates

@rust-log-analyzer

This comment has been minimized.

@fmease
fmease force-pushed the parser-where-clauses-fixes branch 4 times, most recently from 8425e6b to db5181f Compare October 31, 2026 22:05
@rust-log-analyzer

This comment has been minimized.

@fmease
fmease force-pushed the parser-where-clauses-fixes branch 2 times, most recently from ff47213 to 668b5c9 Compare October 31, 2026 22:58
@fmease fmease changed the title Fix where clause parsing for type aliases & const items Fix where clause parsing of type aliases & const items Nov 1, 2026
@rust-bors

This comment has been minimized.

@fmease
fmease force-pushed the parser-where-clauses-fixes branch from 668b5c9 to 3dbebfe Compare November 2, 2026 23:16
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@fmease
fmease force-pushed the parser-where-clauses-fixes branch 2 times, most recently from ceccfbd to 724c67c Compare November 6, 2026 09:45
@rustbot

rustbot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main 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.

@fmease
fmease force-pushed the parser-where-clauses-fixes branch 2 times, most recently from 588a7d9 to 082df29 Compare November 6, 2026 09:47
Previously they were separate because they each contained a fatal parse
error. However, by introducing "barrier functions" we give the parser
synchronization points to successfully recover from these syntax errors
allowing us to put both test cases into the same file.

We call the combined file `where-clause-predicates.rs` because it took me
a while to realize that this test mainly means to test where clause
predicates themselves and not *type aliases with where clauses*.
See also PR RUST-39158 which introduced these files and which is about
"bound parsing" in general.

This makes it alot clearer which UI tests actually concern where clauses
on type aliases *specifically* allowing me to more easily find an
existing test file I can extend with test cases covering "double where
clauses",
namely `tests/ui/where-clauses/where-clause-placement-type-alias.rs`.
There's no reason to return a large tuple that the caller then has to
convert into an `ItemKind`. None of the callers care about the concrete
fields.

In the case of `parse_const_item` it's likely a remnant of the time when
it was used to parse (or rather finish parsing) const (`ItemKind::Const`)
*and* static items (`ItemKind::Static`).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants