Skip to content

Conversation

@fmease
Copy link
Member

@fmease fmease commented Feb 6, 2026

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_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.

@fmease fmease added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Feb 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 6, 2026

Some changes occurred in need_type_info.rs

cc @lcnr

@rustbot rustbot 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 6, 2026

r? @petrochenkov

rustbot has assigned @petrochenkov.
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, types
  • compiler, types expanded to 23 candidates
  • Random selection from 13 candidates

@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 7, 2026

r? BoxyUwU

@rustbot rustbot assigned BoxyUwU and unassigned petrochenkov Feb 7, 2026
@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 7, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 7, 2026

📌 Commit 5ea37f7 has been approved by BoxyUwU

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Feb 7, 2026
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-bors rust-bors bot merged commit 725eb60 into rust-lang:main Feb 8, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 8, 2026
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.
@fmease fmease deleted the has-own-self branch February 8, 2026 08:39
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants