Skip to content

Conversation

@Zalathar
Copy link
Member

While trying to add a new unstable --print kind for use by compiletest, I found that the relevant code is quite awkward to work with, for a few reasons:

  • It's spread across various parts of a multi-thousand-line source file.
  • All newly-added PrintKind values are automatically treated as stable, unless they are explicitly marked as unstable in a helper function far away.
  • Parsing --print values relies on a separate table of name/value mappings, but there's no exhaustiveness check for that table.

This PR therefore:

  • Extracts the relevant code into its own print_request submodule.
  • Uses a macro-rules derive to obtain an exhaustive list of values.
  • Uses exhaustive matches to associate a name and stability status with each PrintKind value.

The first commit moves code to a separate module; the second commit contains actual changes.

There should be no change to compiler output.

@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 Nov 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2025

r? @WaffleLapkin

rustbot has assigned @WaffleLapkin.
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

@Zalathar
Copy link
Member Author

Because r-a doesn't support macro-rules derives yet (rust-lang/rust-analyzer#21043), autocomplete fails for any items introduced by the derive. So I've been reluctant to macro-rules derives more widely within the compiler.

But in this case there's a relatively simple workaround, which is to alias the trait associated constant to a regular associated constant.

Copy link
Member

@WaffleLapkin WaffleLapkin left a comment

Choose a reason for hiding this comment

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

@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2025

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.

@Zalathar
Copy link
Member Author

Rebased and addressed the nit; waiting on PR CI.

@Zalathar
Copy link
Member Author

@bors r=WaffleLapkin

@bors
Copy link
Collaborator

bors commented Nov 21, 2025

📌 Commit 9c7e7cc has been approved by WaffleLapkin

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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 21, 2025
bors added a commit that referenced this pull request Nov 21, 2025
Exhaustively specify names and stability of `--print` values

While trying to add a new unstable `--print` kind for use by compiletest, I found that the relevant code is quite awkward to work with, for a few reasons:

- It's spread across various parts of a multi-thousand-line source file.
- All newly-added `PrintKind` values are automatically treated as *stable*, unless they are explicitly marked as unstable in a helper function far away.
- Parsing `--print` values relies on a separate table of name/value mappings, but there's no exhaustiveness check for that table.

This PR therefore:
- Extracts the relevant code into its own `print_request` submodule.
- Uses a macro-rules derive to obtain an exhaustive list of values.
- Uses exhaustive matches to associate a name and stability status with each `PrintKind` value.

---

The first commit moves code to a separate module; the second commit contains actual changes.

There should be no change to compiler output.
@bors
Copy link
Collaborator

bors commented Nov 21, 2025

⌛ Testing commit 9c7e7cc with merge c3a9f93...

@Zalathar
Copy link
Member Author

Yielding to enclosing rollup.

@bors retry

bors added a commit that referenced this pull request Nov 21, 2025
Rollup of 5 pull requests

Successful merges:

 - #148990 (Exhaustively specify names and stability of `--print` values)
 - #149127 (unwrap ret ty of `iter::ArrayChunks::into_remainder` )
 - #149134 (std: sys: net: uefi: Implement read_vectored)
 - #149135 (Constify `residual_into_try_type`)
 - #149160 (Check for intrinsic to fn ptr casts in unified coercions)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit be1e129 into rust-lang:main Nov 21, 2025
11 of 12 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 21, 2025
@bors
Copy link
Collaborator

bors commented Nov 21, 2025

⌛ Testing commit 9c7e7cc with merge e22dab3...

rust-timer added a commit that referenced this pull request Nov 21, 2025
Rollup merge of #148990 - Zalathar:print-kind, r=WaffleLapkin

Exhaustively specify names and stability of `--print` values

While trying to add a new unstable `--print` kind for use by compiletest, I found that the relevant code is quite awkward to work with, for a few reasons:

- It's spread across various parts of a multi-thousand-line source file.
- All newly-added `PrintKind` values are automatically treated as *stable*, unless they are explicitly marked as unstable in a helper function far away.
- Parsing `--print` values relies on a separate table of name/value mappings, but there's no exhaustiveness check for that table.

This PR therefore:
- Extracts the relevant code into its own `print_request` submodule.
- Uses a macro-rules derive to obtain an exhaustive list of values.
- Uses exhaustive matches to associate a name and stability status with each `PrintKind` value.

---

The first commit moves code to a separate module; the second commit contains actual changes.

There should be no change to compiler output.
@Zalathar Zalathar deleted the print-kind branch November 21, 2025 07:28
@Zalathar
Copy link
Member Author

Bors no, this has already merged.

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 21, 2025
@Kobzol
Copy link
Member

Kobzol commented Nov 21, 2025

@bors r- retry

@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 Nov 21, 2025
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants