Add documentation for some rustc_type_ir macros - #2939
Open
Jamesbarford wants to merge 2 commits into
Open
Conversation
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 |
Jamesbarford
force-pushed
the
chore/rustc_type_ir-macro-docs
branch
from
July 22, 2026 14:36
5531647 to
5efc986
Compare
Author
|
r? @lcnr |
Jamesbarford
force-pushed
the
chore/rustc_type_ir-macro-docs
branch
from
July 28, 2026 09:32
5efc986 to
2df844b
Compare
lcnr
reviewed
Jul 29, 2026
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` |
Contributor
There was a problem hiding this comment.
instead explain this as part of the first paragraph of the GenericTypeVisitable section?
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`. |
Contributor
There was a problem hiding this comment.
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`. |
|
|
||
| Derives `rustc_type_ir::GenericTypeVisitable<V>` for a struct or enum. | ||
|
|
||
| This is the non-nightly, rust-analyzer-facing generic traversal. The visitor |
Contributor
There was a problem hiding this comment.
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 |
…ts earlier in the doc & reword GenericTypeVisitable intro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds documentation for;
TypeVisitable_GenericTypeFoldable_GenericLift_GenericGenericTypeVisitableFollows a formulaic "<macro_name>, description, how to use it, What its expansion does"