Skip to content

Expose more info about ADTs and functions in rustc_public - #157993

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
erickt:rustc-public
Jul 13, 2026
Merged

Expose more info about ADTs and functions in rustc_public#157993
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
erickt:rustc-public

Conversation

@erickt

@erickterickt commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

This allows users of rustc_public to do more complex navigation through data structures by exposing the following info:

  • AdtDef::generics_of - Get the generics for the ADT.
  • AdtDef::inherent_impls - Get all the impls for the ADT.
  • FnDef::associated_item - Get the trait or impl block that contains the function if it exists.
  • FnDef::generics_of - get the generics for a given function.
  • ImplDef::generics_of - Get the generics for the impl block.
  • ImplDef implements CrateDefType - figure out the type of the impl block with CrateDefType::ty() or get the normalized type with CrateDefType::ty_with_args().

This was partially written with the help of Gemini, but I reviewed the code it generated.

@rustbot

Copy link
Copy Markdown
Collaborator

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

@rustbotrustbot 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 Jun 16, 2026
@rustbot

Copy link
Copy Markdown
Collaborator

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
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 73 candidates
  • Random selection from 20 candidates

@rustbot

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.

@makai410makai410 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

r? me

I'll review this in the next few days.

View changes since this review

@rustbotrustbot assigned makai410 and unassigned TaKO8KiJun 17, 2026
@erickt

Copy link
Copy Markdown
ContributorAuthor

@makai410 - gentle ping on this in case this fell off of your radar. Happy to make any changes, or talk through it here over zulip.

@makai410

Copy link
Copy Markdown
Member

Sorry for the delay. I've been busy irl, but I'll be able to review this after July 5th.

@makai410makai410 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! The overall changes look good to me, r=me when you resolve the comment.

Comment threadcompiler/rustc_public/src/compiler_interface.rs Outdated
@makai410

Copy link
Copy Markdown
Member

@rustbot author

@rustbotrustbot 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 Jul 6, 2026
@rustbot

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

This allows users of `rustc_public` to do more complex navigation
through data structures by exposing the following info:
* `AdtDef::generics_of` - Get the generics for the ADT.
* `AdtDef::inherent_impls` - Get all the impls for the ADT.
* `FnDef::associated_item` - Get the trait or impl block that contains the
function if it exists.
* `FnDef::generics_of` - get the generics for a given function.
* `ImplDef::generics_of` - Get the generics for the impl block.
* `ImplDef` implements `CrateDefType` - figure out the type of the impl
block with `CrateDefType::ty()` or get the normalized type with
`CrateDefType::ty_with_args()`.
This was partially written with the help of Gemini, but I reviewed the
code it generated.
@erickt

Copy link
Copy Markdown
ContributorAuthor

@rustbot ready

@rustbotrustbot 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 Jul 9, 2026

@makai410makai410 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rust-bors

rust-borsBot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5f4114c has been approved by makai410

It is now in the queue for this repository.

@rust-borsrust-borsBot 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 Jul 13, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 13, 2026
Expose more info about ADTs and functions in rustc_public
This allows users of `rustc_public` to do more complex navigation through data structures by exposing the following info:
* `AdtDef::generics_of` - Get the generics for the ADT.
* `AdtDef::inherent_impls` - Get all the impls for the ADT.
* `FnDef::associated_item` - Get the trait or impl block that contains the function if it exists.
* `FnDef::generics_of` - get the generics for a given function.
* `ImplDef::generics_of` - Get the generics for the impl block.
* `ImplDef` implements `CrateDefType` - figure out the type of the impl block with `CrateDefType::ty()` or get the normalized type with `CrateDefType::ty_with_args()`.
This was partially written with the help of Gemini, but I reviewed the code it generated.
rust-borsBot pushed a commit that referenced this pull request Jul 13, 2026
…uwer
Rollup of 14 pull requests
Successful merges:
- #159039 (resolve: fix effective visibilities for items in ambiguous glob sets)
- #157706 (Deny `todo!()` in tidy)
- #158535 (Support `#[track_caller]` on EII declarations)
- #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- #158846 (Fix unused variable warnings for diverging expressions)
- #159002 (Small refactorings in `need_type_info` module)
- #159202 (Bump rustc-demangle to 0.1.28)
- #159216 (Avoid using probe self_ty for delegation arguments)
- #159222 (semicolon_in_expressions_from_macros: Lint on non-local macros too)
- #156609 (Consider structurally impossible Sized predicates in MIR)
- #157993 (Expose more info about ADTs and functions in rustc_public)
- #158854 (Add `#[rustc_test_entrypoint_marker]`)
- #158998 (Some minor ast validation and visiting cleanups)
- #159123 (doc: clarify attr parser APIs)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 13, 2026
Expose more info about ADTs and functions in rustc_public
This allows users of `rustc_public` to do more complex navigation through data structures by exposing the following info:
* `AdtDef::generics_of` - Get the generics for the ADT.
* `AdtDef::inherent_impls` - Get all the impls for the ADT.
* `FnDef::associated_item` - Get the trait or impl block that contains the function if it exists.
* `FnDef::generics_of` - get the generics for a given function.
* `ImplDef::generics_of` - Get the generics for the impl block.
* `ImplDef` implements `CrateDefType` - figure out the type of the impl block with `CrateDefType::ty()` or get the normalized type with `CrateDefType::ty_with_args()`.
This was partially written with the help of Gemini, but I reviewed the code it generated.
rust-borsBot pushed a commit that referenced this pull request Jul 13, 2026
…uwer
Rollup of 15 pull requests
Successful merges:
- #159039 (resolve: fix effective visibilities for items in ambiguous glob sets)
- #157706 (Deny `todo!()` in tidy)
- #156047 (Fix trait method resolution on an adjusted never type)
- #158535 (Support `#[track_caller]` on EII declarations)
- #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- #158846 (Fix unused variable warnings for diverging expressions)
- #159002 (Small refactorings in `need_type_info` module)
- #159202 (Bump rustc-demangle to 0.1.28)
- #159216 (Avoid using probe self_ty for delegation arguments)
- #156609 (Consider structurally impossible Sized predicates in MIR)
- #157993 (Expose more info about ADTs and functions in rustc_public)
- #158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- #158854 (Add `#[rustc_test_entrypoint_marker]`)
- #158998 (Some minor ast validation and visiting cleanups)
- #159123 (doc: clarify attr parser APIs)
rust-borsBot pushed a commit that referenced this pull request Jul 13, 2026
…uwer
Rollup of 13 pull requests
Successful merges:
- #157706 (Deny `todo!()` in tidy)
- #158535 (Support `#[track_caller]` on EII declarations)
- #158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- #158846 (Fix unused variable warnings for diverging expressions)
- #159002 (Small refactorings in `need_type_info` module)
- #159202 (Bump rustc-demangle to 0.1.28)
- #159216 (Avoid using probe self_ty for delegation arguments)
- #156609 (Consider structurally impossible Sized predicates in MIR)
- #157993 (Expose more info about ADTs and functions in rustc_public)
- #158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- #158854 (Add `#[rustc_test_entrypoint_marker]`)
- #158998 (Some minor ast validation and visiting cleanups)
- #159123 (doc: clarify attr parser APIs)
@rust-bors
rust-borsBot merged commit c6e5644 into rust-lang:mainJul 13, 2026
13 checks passed
@rustbotrustbot added this to the 1.99.0 milestone Jul 13, 2026
rust-timer added a commit that referenced this pull request Jul 13, 2026
Rollup merge of #157993 - erickt:rustc-public, r=makai410
Expose more info about ADTs and functions in rustc_public
This allows users of `rustc_public` to do more complex navigation through data structures by exposing the following info:
* `AdtDef::generics_of` - Get the generics for the ADT.
* `AdtDef::inherent_impls` - Get all the impls for the ADT.
* `FnDef::associated_item` - Get the trait or impl block that contains the function if it exists.
* `FnDef::generics_of` - get the generics for a given function.
* `ImplDef::generics_of` - Get the generics for the impl block.
* `ImplDef` implements `CrateDefType` - figure out the type of the impl block with `CrateDefType::ty()` or get the normalized type with `CrateDefType::ty_with_args()`.
This was partially written with the help of Gemini, but I reviewed the code it generated.
github-actionsBot pushed a commit to rust-lang/stdarch that referenced this pull request Jul 16, 2026
…uwer
Rollup of 13 pull requests
Successful merges:
- rust-lang/rust#157706 (Deny `todo!()` in tidy)
- rust-lang/rust#158535 (Support `#[track_caller]` on EII declarations)
- rust-lang/rust#158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- rust-lang/rust#158846 (Fix unused variable warnings for diverging expressions)
- rust-lang/rust#159002 (Small refactorings in `need_type_info` module)
- rust-lang/rust#159202 (Bump rustc-demangle to 0.1.28)
- rust-lang/rust#159216 (Avoid using probe self_ty for delegation arguments)
- rust-lang/rust#156609 (Consider structurally impossible Sized predicates in MIR)
- rust-lang/rust#157993 (Expose more info about ADTs and functions in rustc_public)
- rust-lang/rust#158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- rust-lang/rust#158854 (Add `#[rustc_test_entrypoint_marker]`)
- rust-lang/rust#158998 (Some minor ast validation and visiting cleanups)
- rust-lang/rust#159123 (doc: clarify attr parser APIs)
@Kobzol

Copy link
Copy Markdown
Member

@rust-timer build 45fbcd0

For #159246.

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (45fbcd0): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-1.8%[-2.5%, -0.5%]14
All ❌✅ (primary)--0

Max RSS (memory usage)

Results (primary 2.3%, secondary -16.7%)

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

meanrangecount
Regressions ❌
(primary)
2.3%[2.3%, 2.3%]1
Regressions ❌
(secondary)
0.9%[0.9%, 0.9%]1
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-17.8%[-23.5%, -4.2%]15
All ❌✅ (primary)2.3%[2.3%, 2.3%]1

Cycles

Results (primary 2.4%, secondary -12.6%)

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

meanrangecount
Regressions ❌
(primary)
2.4%[2.4%, 2.4%]1
Regressions ❌
(secondary)
2.3%[2.3%, 2.3%]1
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-13.6%[-19.5%, -5.3%]14
All ❌✅ (primary)2.4%[2.4%, 2.4%]1

Binary size

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

Bootstrap: 488.117s -> 487.953s (-0.03%)
Artifact size: 389.87 MiB -> 389.14 MiB (-0.19%)

Kobzol pushed a commit to Kobzol/rustc_codegen_cranelift that referenced this pull request Jul 23, 2026
…uwer
Rollup of 13 pull requests
Successful merges:
- rust-lang/rust#157706 (Deny `todo!()` in tidy)
- rust-lang/rust#158535 (Support `#[track_caller]` on EII declarations)
- rust-lang/rust#158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- rust-lang/rust#158846 (Fix unused variable warnings for diverging expressions)
- rust-lang/rust#159002 (Small refactorings in `need_type_info` module)
- rust-lang/rust#159202 (Bump rustc-demangle to 0.1.28)
- rust-lang/rust#159216 (Avoid using probe self_ty for delegation arguments)
- rust-lang/rust#156609 (Consider structurally impossible Sized predicates in MIR)
- rust-lang/rust#157993 (Expose more info about ADTs and functions in rustc_public)
- rust-lang/rust#158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- rust-lang/rust#158854 (Add `#[rustc_test_entrypoint_marker]`)
- rust-lang/rust#158998 (Some minor ast validation and visiting cleanups)
- rust-lang/rust#159123 (doc: clarify attr parser APIs)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Aug 17, 2026
…uwer
Rollup of 13 pull requests
Successful merges:
- rust-lang/rust#157706 (Deny `todo!()` in tidy)
- rust-lang/rust#158535 (Support `#[track_caller]` on EII declarations)
- rust-lang/rust#158632 (First steps of late-bound turbofishing (place FnDef behind a dummy binder))
- rust-lang/rust#158846 (Fix unused variable warnings for diverging expressions)
- rust-lang/rust#159002 (Small refactorings in `need_type_info` module)
- rust-lang/rust#159202 (Bump rustc-demangle to 0.1.28)
- rust-lang/rust#159216 (Avoid using probe self_ty for delegation arguments)
- rust-lang/rust#156609 (Consider structurally impossible Sized predicates in MIR)
- rust-lang/rust#157993 (Expose more info about ADTs and functions in rustc_public)
- rust-lang/rust#158804 (Clarify `as_uninit_mut` may point to uninitialized memory)
- rust-lang/rust#158854 (Add `#[rustc_test_entrypoint_marker]`)
- rust-lang/rust#158998 (Some minor ast validation and visiting cleanups)
- rust-lang/rust#159123 (doc: clarify attr parser APIs)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

6 participants

@erickt@rustbot@makai410@Kobzol@rust-timer@TaKO8Ki