Skip to content

Add documentation for some rustc_type_ir macros - #2939

Open
Jamesbarford wants to merge 2 commits into
rust-lang:mainfrom
Jamesbarford:chore/rustc_type_ir-macro-docs
Open

Add documentation for some rustc_type_ir macros#2939
Jamesbarford wants to merge 2 commits into
rust-lang:mainfrom
Jamesbarford:chore/rustc_type_ir-macro-docs

Conversation

@Jamesbarford

Copy link
Copy Markdown

Adds documentation for;

  • TypeVisitable_Generic
  • TypeFoldable_Generic
  • Lift_Generic
  • GenericTypeVisitable

Follows a formulaic "<macro_name>, description, how to use it, What its expansion does"

@rustbot

rustbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR. If you have write access, feel free to merge this PR if it does not need reviews. You can request a review using r? rustc-dev-guide or r? <username>.

@rustbot rustbot added the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Jul 22, 2026
@Jamesbarford
Jamesbarford force-pushed the chore/rustc_type_ir-macro-docs branch from 5531647 to 5efc986 Compare July 22, 2026 14:36
@Jamesbarford

Copy link
Copy Markdown
Author

r? @lcnr

@Jamesbarford
Jamesbarford force-pushed the chore/rustc_type_ir-macro-docs branch from 5efc986 to 2df844b Compare July 28, 2026 09:32
Comment on lines +242 to +253
### `GenericTypeVisitable` & `TypeVisitable_Generic`

While ostensibly similar due to their names, they implement two different
visiting systems.

- `TypeVisitable_Generic` means: derive the ordinary `TypeVisitable` trait
generically over an `Interner`.
- `GenericTypeVisitable` means: derive the separate `GenericTypeVisitable` trait
used by non-nightly consumers such as rust-analyzer.

As such a struct or enum can derive both `TypeVisitable_Generic` and
`GenericTypeVisitable`

@lcnr lcnr Jul 29, 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.

instead explain this as part of the first paragraph of the GenericTypeVisitable section?

View changes since the review

Comment on lines +148 to +155
`rustc_type_ir` makes _heavy_ use of a few macros, in particular
- [`Lift_Generic`][lift_generic]
- [`TypeFoldable_Generic`][typefoldable_generic]
- [`TypeVisitable_Generic`][typevisitable_generic]
- [`GenericTypeVisitable`][generictypevisitable]

Of which primarily exist to reduce the amount of boilerplate otherwise
required to implement `TypeFoldable`, `TypeVisitable` and `Lift`.

@lcnr lcnr Jul 29, 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.

Suggested change
`rustc_type_ir` makes _heavy_ use of a few macros, in particular
- [`Lift_Generic`][lift_generic]
- [`TypeFoldable_Generic`][typefoldable_generic]
- [`TypeVisitable_Generic`][typevisitable_generic]
- [`GenericTypeVisitable`][generictypevisitable]
Of which primarily exist to reduce the amount of boilerplate otherwise
required to implement `TypeFoldable`, `TypeVisitable` and `Lift`.
`rustc_type_ir` makes _heavy_ use of a few macros, in particular
- [`Lift_Generic`][lift_generic]
- [`TypeFoldable_Generic`][typefoldable_generic]
- [`TypeVisitable_Generic`][typevisitable_generic]
- [`GenericTypeVisitable`][generictypevisitable]
Of which primarily exist to reduce the amount of boilerplate otherwise
required to implement `TypeFoldable`, `TypeVisitable` and `Lift`.
These macros are variants of the `TypeFoldable`, `TypeVisitable`, and `Lift` macros used in crates which have access to the `TyCtxt` using a `I: Interner` parameter instead of `TyCtxt`.

View changes since the review


Derives `rustc_type_ir::GenericTypeVisitable<V>` for a struct or enum.

This is the non-nightly, rust-analyzer-facing generic traversal. The visitor

@lcnr lcnr Jul 29, 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.

Suggested change
This is the non-nightly, rust-analyzer-facing generic traversal. The visitor
This a separate more general traversal trait purely used by rust-analyzer. The visitor

View changes since the review

@lcnr lcnr added S-waiting-on-author Status: this PR is waiting for additional action by the OP and removed S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content labels Jul 29, 2026
…ts earlier in the doc & reword GenericTypeVisitable intro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: this PR is waiting for additional action by the OP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants