Skip to content

Add tests and docs for #[derive(GenericTypeVisitable)] - #161806

Open
ada4a wants to merge 4 commits into
rust-lang:mainfrom
ada4a:push-olrruxoktqnl
Open

Add tests and docs for #[derive(GenericTypeVisitable)]#161806
ada4a wants to merge 4 commits into
rust-lang:mainfrom
ada4a:push-olrruxoktqnl

Conversation

@ada4a

@ada4a ada4a commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

..given the added complexity from the newly-added bounds attribute

Follow-up to #160914

More details in individual commits.

cc @JonathanBrouwer (you might want to take over the review of this since you have some context already.. but as you wish)
cc @ChayimFriedman2

ada4a added 4 commits August 24, 2026 11:53
I ended up deciding not to add docs about `bounds` as it seems like a
relatively minor feature of the derive, and there are docs at [1].

[1]: https://github.com/rust-lang/rust/blob/3ffb26fbf5bf232cf59e314e75ea325973f4f583/compiler/rustc_type_ir_macros/src/lib.rs#L21-L55
Just specifying `T: GenericTypeVisitable` doesn't work, as the trait has
a generic: `V`, the visitor. `T: GenericTypeVisitable<__V>` is what
actually works, as `__V` is the generic added to the impl generated by
the derive macro.

We discussed[1] different ways of making this nicer, but settled on not
doing anything, as we don't expect people to need to specify any actual
bounds.

[1]: https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/Updating.20next-solver/near/618331780
     and below
@rustbot

rustbot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

rustc-dev-guide is developed in its own repository. If possible, consider making this change to rust-lang/rustc-dev-guide instead.

cc @BoxyUwU, @tshepang

@rustbot rustbot added 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 Aug 26, 2026
@rustbot

rustbot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

r? @mejrs

rustbot has assigned @mejrs.
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 75 candidates
  • Random selection from 19 candidates

@JonathanBrouwer

Copy link
Copy Markdown
Member

r? me
Yeah I can take this, feel free to just assign to me in the future :3

@rustbot rustbot assigned JonathanBrouwer and unassigned mejrs Aug 26, 2026
use rustc_type_ir::{GenericTypeVisitable, Interner};
use rustc_type_ir_macros::GenericTypeVisitable;

#[derive(GenericTypeVisitable)]

@JonathanBrouwer JonathanBrouwer Aug 26, 2026

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.

It would be nice to make this into a run-pass test that uses it's main function to test the implementation of GenericTypeVisitable. Doesn't have to be for all of the types in the file if you don't feel like it, but having some coverage of the implementation is good

View changes since the review


#[derive(GenericTypeVisitable)]
struct MissingBound<T> {
// This should fail, as `T: GenericTypeVisitable<__V>` wasn't specified

@JonathanBrouwer JonathanBrouwer Aug 26, 2026

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.

I guess you need to split this into it's own file then

View changes since the review

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

rustbot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

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

@JonathanBrouwer

Copy link
Copy Markdown
Member

Other than that this looks good to me, thanks!

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

Labels

A-rustc-dev-guide Area: rustc-dev-guide S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants