Skip to content

Add #[rustc_dump_generics] attribute#157384

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
addiesh:turbofisherwoman
Jun 19, 2026
Merged

Add #[rustc_dump_generics] attribute#157384
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
addiesh:turbofisherwoman

Conversation

@addiesh

@addiesh addiesh commented Jun 3, 2026

Copy link
Copy Markdown

View all comments

Added a rustc attribute to dump the generic parameters of a given item to the compiler output.

@rustbot

rustbot commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann, @JonathanBrouwer

The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes.

cc @BoxyUwU, @tshepang

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustc-dev-guide Area: rustc-dev-guide 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 Jun 3, 2026
@rustbot

rustbot commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @oli-obk (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

Comment thread compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs
Comment thread compiler/rustc_hir_analysis/src/collect/dump.rs Outdated
@addiesh addiesh force-pushed the turbofisherwoman branch from c240b2b to 08cf89c Compare June 3, 2026 15:27
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jdonszelmann jdonszelmann self-assigned this Jun 4, 2026
@jdonszelmann

Copy link
Copy Markdown
Contributor

I can review the attrs part!

Allow(Target::Struct),
Allow(Target::Enum),
Allow(Target::Union),
Allow(Target::Trait),

@jdonszelmann jdonszelmann Jun 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You'll probably want a test using it on a trait some day, because I imagine the interaction can be a bit more involved for that. Im not quite sure how far along this is from proof of concept to done. You might want to initially not support traits if that test gives you trouble?

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Just added a test for a trait, but it's definitely not exhaustive. Let me know your thoughts.

Comment thread compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/collect/dump.rs Outdated
Comment thread compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs
Comment thread compiler/rustc_hir_analysis/src/collect/dump.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/collect/dump.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/collect/dump.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/collect/dump.rs Outdated
Comment thread library/backtrace
@addiesh addiesh marked this pull request as draft June 8, 2026 16:27
@rustbot rustbot 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 Jun 8, 2026
@addiesh addiesh force-pushed the turbofisherwoman branch from 2bae2d2 to 7f0f6e0 Compare June 10, 2026 14:50
@addiesh addiesh marked this pull request as ready for review June 10, 2026 14:58
@rustbot rustbot 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 Jun 10, 2026
@oli-obk

oli-obk commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7f0f6e0 has been approved by oli-obk

It is now in the queue for this repository.

@rustbot

rustbot commented Jun 11, 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.

@mejrs

mejrs commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@bors try jobs=i686-gnu-nopt-1

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 11, 2026
Add `#[rustc_dump_generics]` attribute


try-job: i686-gnu-nopt-1
@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 11, 2026
@rust-bors

rust-bors Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 87945f8 failed: CI. Failed job:

@rust-log-analyzer

This comment has been minimized.

@addiesh

addiesh commented Jun 11, 2026

Copy link
Copy Markdown
Author

That's frustrating. Why does it fail specifically on that target triple?

@fmease

fmease commented Jun 11, 2026

Copy link
Copy Markdown
Member

The specific target doesn't matter. You're printing a FxHashMap (param_def_id_to_index) whose entries don't have a "stable ordering" due to the hashing (it happens to be stable across compilations & re-runs but the behavior may differ by target; i686-gnu-nopt-1 differs most likely because it's a 32-bit arch).

You need to add another compiletest normalization rule to make the mapping stable by "normalizing away" the concrete indices.

@addiesh

addiesh commented Jun 11, 2026

Copy link
Copy Markdown
Author

The specific target doesn't matter. You're printing a FxHashMap (param_def_id_to_index) whose entries don't have a "stable ordering" due to the hashing (it happens to be stable across compilations & re-runs but the behavior may differ by target; i686-gnu-nopt-1 differs most likely because it's a 32-bit arch).

You somehow need to compiletest-normalize away this mapping in the output.

Ah, I see. That makes sense. I'll try my best to do that.

@jdonszelmann

Copy link
Copy Markdown
Contributor

@bors try jobs=i686-gnu-nopt-1

rust-bors Bot pushed a commit that referenced this pull request Jun 15, 2026
Add `#[rustc_dump_generics]` attribute


try-job: i686-gnu-nopt-1
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 6d5e939 (6d5e9394265d10fa066c6c9497c5e5aab0c7befa, parent: 5ff740e85e8569289a93573ad25f1295dfae0323)

@addiesh

addiesh commented Jun 19, 2026

Copy link
Copy Markdown
Author

bump; this should be ready to merge

@addiesh

addiesh commented Jun 19, 2026

Copy link
Copy Markdown
Author

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@addiesh: 🔑 Insufficient privileges: not in review users

@WaffleLapkin

Copy link
Copy Markdown
Member

@bors r=oli-obk
(per #157384 (comment) and #157384 (comment))

@rust-bors

rust-bors Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit fa0e9bd has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jun 19, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 19, 2026
@rust-bors

rust-bors Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: oli-obk
Duration: 3h 9m 6s
Pushing 8e15021 to main...

@rust-bors rust-bors Bot merged commit 8e15021 into rust-lang:main Jun 19, 2026
15 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 8c3f167 (parent) -> 8e15021 (this PR)

Test differences

Show 3 test diffs

Stage 1

  • [ui] tests/ui/attributes/dump_generics.rs: [missing] -> pass (J0)
  • [ui (polonius)] tests/ui/attributes/dump_generics.rs: [missing] -> pass (J2)

Stage 2

  • [ui] tests/ui/attributes/dump_generics.rs: [missing] -> pass (J1)

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 8e150217bafcaaaa0c45bf685c55fd56cec48598 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-gcc-core-tests: 7m 37s -> 14m 20s (+88.1%)
  2. x86_64-gnu-pre-stabilization: 25m 38s -> 37m 9s (+45.0%)
  3. x86_64-gnu-debug: 1h 55m -> 1h 16m (-33.5%)
  4. dist-powerpc64-linux-gnu: 1h 13m -> 1h 35m (+29.5%)
  5. x86_64-msvc-2: 1h 50m -> 2h 20m (+27.2%)
  6. dist-ohos-armv7: 1h 10m -> 51m 35s (-26.5%)
  7. dist-powerpc64le-linux-musl: 1h 36m -> 1h 14m (-22.6%)
  8. dist-powerpc64le-linux-gnu: 1h 37m -> 1h 15m (-22.2%)
  9. pr-check-2: 37m 8s -> 44m 53s (+20.8%)
  10. i686-gnu-nopt-1: 1h 58m -> 2h 22m (+20.3%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (8e15021): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary -1.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.0% [-1.0%, -1.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.0% [-1.0%, -1.0%] 1

Cycles

Results (primary 1.9%, secondary -4.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.9% [1.9%, 1.9%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.4% [-5.8%, -2.9%] 2
All ❌✅ (primary) 1.9% [1.9%, 1.9%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 480.598s -> 481.812s (0.25%)
Artifact size: 390.74 MiB -> 390.71 MiB (-0.01%)

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustc-dev-guide Area: rustc-dev-guide merged-by-bors This PR was explicitly merged by bors. 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.