-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Introduce helper ty::Generics::has_own_self
#152261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+9
−6
Conversation
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
Collaborator
|
Some changes occurred in need_type_info.rs cc @lcnr |
Collaborator
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Member
|
r? BoxyUwU |
Member
|
@bors r+ rollup |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 7, 2026
Introduce helper `ty::Generics::has_own_self` The pattern `generics.has_self && generics.parent.is_none()` only occurs 5 times in rustc+rustdoc at the time of writing but I keep getting reminded/annoyed that there doesn't exist a nice wrapper fn that abstracts it & immediately clarifies the intent. Most recently that happened when working on my open PR RUST-129543 in which I add yet another occurrence of it ([via](https://github.com/fmease/rust/blob/ae8c0a5a46364b0d0bca349cba544adb762e7c0a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs#L1771-L1773)). For context, `generics.has_self` indicates that there is a `Self` type parameter (at position 0) in the "oldest" / "root" generic parameter list in the chain of generic parameter lists (rephrased: it's true if the chain *as a whole* has a `Self` type parameter). `has_own_self` on the other hand indicates that the `own_params` contain a `Self` type parameter which is sometimes needed for offsetting the own parameters or arguments.
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 7, 2026
Introduce helper `ty::Generics::has_own_self` The pattern `generics.has_self && generics.parent.is_none()` only occurs 5 times in rustc+rustdoc at the time of writing but I keep getting reminded/annoyed that there doesn't exist a nice wrapper fn that abstracts it & immediately clarifies the intent. Most recently that happened when working on my open PR RUST-129543 in which I add yet another occurrence of it ([via](https://github.com/fmease/rust/blob/ae8c0a5a46364b0d0bca349cba544adb762e7c0a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs#L1771-L1773)). For context, `generics.has_self` indicates that there is a `Self` type parameter (at position 0) in the "oldest" / "root" generic parameter list in the chain of generic parameter lists (rephrased: it's true if the chain *as a whole* has a `Self` type parameter). `has_own_self` on the other hand indicates that the `own_params` contain a `Self` type parameter which is sometimes needed for offsetting the own parameters or arguments.
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 7, 2026
…uwer Rollup of 7 pull requests Successful merges: - #151745 (Remove a couple of unnecessary flags and env vars in bootstrap) - #152217 (Convert to inline diagnostics in `rustc_lint`) - #152056 (RwLock: refine documentation to emphasize non-reentrancy guarantees) - #152261 (Introduce helper `ty::Generics::has_own_self`) - #152288 (Allow only a single accepter per attribute) - #152292 (Minor change for readability) - #152300 (Port `rustc_regions` to the new attribute parser)
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 7, 2026
…uwer Rollup of 7 pull requests Successful merges: - #151745 (Remove a couple of unnecessary flags and env vars in bootstrap) - #152217 (Convert to inline diagnostics in `rustc_lint`) - #152056 (RwLock: refine documentation to emphasize non-reentrancy guarantees) - #152261 (Introduce helper `ty::Generics::has_own_self`) - #152288 (Allow only a single accepter per attribute) - #152292 (Minor change for readability) - #152300 (Port `rustc_regions` to the new attribute parser)
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 7, 2026
…uwer Rollup of 7 pull requests Successful merges: - #151745 (Remove a couple of unnecessary flags and env vars in bootstrap) - #152217 (Convert to inline diagnostics in `rustc_lint`) - #152056 (RwLock: refine documentation to emphasize non-reentrancy guarantees) - #152261 (Introduce helper `ty::Generics::has_own_self`) - #152288 (Allow only a single accepter per attribute) - #152292 (Minor change for readability) - #152300 (Port `rustc_regions` to the new attribute parser)
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 7, 2026
…uwer Rollup of 7 pull requests Successful merges: - #151745 (Remove a couple of unnecessary flags and env vars in bootstrap) - #152217 (Convert to inline diagnostics in `rustc_lint`) - #152056 (RwLock: refine documentation to emphasize non-reentrancy guarantees) - #152261 (Introduce helper `ty::Generics::has_own_self`) - #152288 (Allow only a single accepter per attribute) - #152292 (Minor change for readability) - #152300 (Port `rustc_regions` to the new attribute parser)
rust-timer
added a commit
that referenced
this pull request
Feb 8, 2026
Rollup merge of #152261 - fmease:has-own-self, r=BoxyUwU Introduce helper `ty::Generics::has_own_self` The pattern `generics.has_self && generics.parent.is_none()` only occurs 5 times in rustc+rustdoc at the time of writing but I keep getting reminded/annoyed that there doesn't exist a nice wrapper fn that abstracts it & immediately clarifies the intent. Most recently that happened when working on my open PR RUST-129543 in which I add yet another occurrence of it ([via](https://github.com/fmease/rust/blob/ae8c0a5a46364b0d0bca349cba544adb762e7c0a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs#L1771-L1773)). For context, `generics.has_self` indicates that there is a `Self` type parameter (at position 0) in the "oldest" / "root" generic parameter list in the chain of generic parameter lists (rephrased: it's true if the chain *as a whole* has a `Self` type parameter). `has_own_self` on the other hand indicates that the `own_params` contain a `Self` type parameter which is sometimes needed for offsetting the own parameters or arguments.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
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.
The pattern
generics.has_self && generics.parent.is_none()only occurs 5 times in rustc+rustdoc at the time of writing but I keep getting reminded/annoyed that there doesn't exist a nice wrapper fn that abstracts it & immediately clarifies the intent. Most recently that happened when working on my open PR RUST-129543 in which I add yet another occurrence of it (via).For context,
generics.has_selfindicates that there is aSelftype parameter (at position 0) in the "oldest" / "root" generic parameter list in the chain of generic parameter lists (rephrased: it's true if the chain as a whole has aSelftype parameter).has_own_selfon the other hand indicates that theown_paramscontain aSelftype parameter which is sometimes needed for offsetting the own parameters or arguments.