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.

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

None yet

Development

Successfully merging this pull request may close these issues.

3 participants