Skip to content

Conversation

@jacob-greenfield
Copy link
Contributor

Adds a parent() method to DefId (the rustc_pub version) which exposes the parent path, ie. foo::bar::baz -> foo::bar.

This is useful for organizing/grouping definitions into a tree, and is probably simpler and less brittle than attempting to parse the fully-qualified name into path components (e.g. especially when handling path components with qualified generic parameters).

@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

r? @scottmcm

rustbot has assigned @scottmcm.
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

@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. labels Jul 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@makai410
Copy link
Member

Thanks! Could you please add an ui-test for that, if it's not too much work

@scottmcm
Copy link
Member

Sorry, while I volunteered to help with reviews here I don't really know intent for stuff like this, so re-rolling
r? project-stable-mir

@rustbot rustbot assigned oli-obk and unassigned scottmcm Jul 24, 2025
Copy link
Contributor

@celinval celinval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. Can you please add a test to the new API? You can just augment https://github.com/rust-lang/rust/blob/master/tests/ui-fulldeps/rustc_public/check_defs.rs

r=me when you are done

Copy link
Contributor

@celinval celinval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops... wrong checkbox.

@celinval
Copy link
Contributor

r? celinval

@rustbot rustbot assigned celinval and unassigned oli-obk Jul 25, 2025
@Dylan-DPC Dylan-DPC 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 Oct 1, 2025
@Dylan-DPC
Copy link
Member

@jacob-greenfield can you add the test required for this? that's the only thing pending here.

@bors
Copy link
Collaborator

bors commented Oct 30, 2025

☔ The latest upstream changes (presumably #148280) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Nov 15, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@jacob-greenfield
Copy link
Contributor Author

I've added a new/separate UI test based on tests/ui-fulldeps/rustc_public/check_defs.rs. Sorry for the delay!

Copy link
Contributor

@celinval celinval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@celinval
Copy link
Contributor

Hmmm.. let me try again.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 29, 2025

📌 Commit e9d68a5 has been approved by celinval

It is now in the queue for this repository.

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 29, 2025
bors added a commit that referenced this pull request Nov 29, 2025
Rollup of 3 pull requests

Successful merges:

 - #144000 (Add `DefId::parent()` accessor for `rustc_public`)
 - #149409 (Test the coexistence of 'stack-protector' and 'safe-stack')
 - #149449 (Remove an unnecessary `unwrap` in `rustc_codegen_gcc`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3a0187e into rust-lang:main Nov 29, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 29, 2025
rust-timer added a commit that referenced this pull request Nov 29, 2025
Rollup merge of #144000 - jacob-greenfield:stable-defid-parent, r=celinval

Add `DefId::parent()` accessor for `rustc_public`

Adds a `parent()` method to `DefId` (the `rustc_pub` version) which exposes the parent path, ie. `foo::bar::baz` -> `foo::bar`.

This is useful for organizing/grouping definitions into a tree, and is probably simpler and less brittle than attempting to parse the fully-qualified name into path components (e.g. especially when handling path components with qualified generic parameters).
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Dec 10, 2025
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#144000 (Add `DefId::parent()` accessor for `rustc_public`)
 - rust-lang/rust#149409 (Test the coexistence of 'stack-protector' and 'safe-stack')
 - rust-lang/rust#149449 (Remove an unnecessary `unwrap` in `rustc_codegen_gcc`)

r? `@ghost`
`@rustbot` modify labels: rollup
makai410 pushed a commit to makai410/rust that referenced this pull request Dec 10, 2025
…nt, r=celinval

Add `DefId::parent()` accessor for `rustc_public`

Adds a `parent()` method to `DefId` (the `rustc_pub` version) which exposes the parent path, ie. `foo::bar::baz` -> `foo::bar`.

This is useful for organizing/grouping definitions into a tree, and is probably simpler and less brittle than attempting to parse the fully-qualified name into path components (e.g. especially when handling path components with qualified generic parameters).
makai410 pushed a commit to makai410/rust that referenced this pull request Dec 10, 2025
Rollup of 3 pull requests

Successful merges:

 - rust-lang#144000 (Add `DefId::parent()` accessor for `rustc_public`)
 - rust-lang#149409 (Test the coexistence of 'stack-protector' and 'safe-stack')
 - rust-lang#149449 (Remove an unnecessary `unwrap` in `rustc_codegen_gcc`)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants