Skip to content

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jan 3, 2023

The hir::Map::get_parent_node function doesn't return a Node, and I think that's quite confusing. Let's rename it to something that sounds more like something that gets the parent hir id => hir::Map::parent_id. Same with find_parent_node => opt_parent_id.

Also, combine hir.get(hir.parent_id(hir_id)) and similar hir.find(hir.parent_id(hir_id)) function into new functions that actually retrieve the parent node in one call. This last commit is the only one that might need to be looked at closely.

@rustbot
Copy link
Collaborator

rustbot commented Jan 3, 2023

r? @cjgillot

(rustbot has picked a reviewer for you, use r? to override)

@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 Jan 3, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 3, 2023

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member Author

Well I did something wrong

@rustbot author

@rustbot rustbot 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 Jan 3, 2023
@@ -3456,7 +3456,7 @@ impl<'hir> Node<'hir> {
/// ```ignore (illustrative)
/// ctor
/// .ctor_hir_id()
/// .and_then(|ctor_id| tcx.hir().find(tcx.hir().get_parent_node(ctor_id)))
/// .and_then(|ctor_id| tcx.hir().find_parent_node(ctor_id))
Copy link
Contributor

Choose a reason for hiding this comment

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

At a glance, this seems incorrect.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you be more specific?

get_parent_node(_: HirId) -> HirId was renamed to parent_id(_: HirId) -> HirId, and a new find_parent_node(_: HirId) -> Optiion<Node> was introduced.

Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't you introduce find_parent instead of find_parent_node?
r=me with the comment and PR title corrected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course 🤦

Copy link
Member Author

@compiler-errors compiler-errors Jan 3, 2023

Choose a reason for hiding this comment

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

Wait -- what modification to the PR title do you want? Also mentioning adding {find,get}_parent?

edit: just did that.

@compiler-errors compiler-errors changed the title Rename hir::Map::{get_,find_}parent_node to hir::Map::{,opt_}parent_id Rename hir::Map::{get_,find_}parent_node to hir::Map::{,opt_}parent_id, and add hir::Map::{get,find}_parent Jan 3, 2023
@compiler-errors
Copy link
Member Author

@bors r=cjgillot

@bors
Copy link
Collaborator

bors commented Jan 3, 2023

📌 Commit 59c95178848867f7cfca35dc8ddf2a217ef641f6 has been approved by cjgillot

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 Jan 3, 2023
@bors
Copy link
Collaborator

bors commented Jan 4, 2023

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

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 4, 2023
@compiler-errors
Copy link
Member Author

@bors r=cjgillot

@bors
Copy link
Collaborator

bors commented Jan 4, 2023

📌 Commit b1b19bd has been approved by cjgillot

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 4, 2023
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 4, 2023
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jan 5, 2023
…, r=cjgillot

Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`

The `hir::Map::get_parent_node` function doesn't return a `Node`, and I think that's quite confusing. Let's rename it to something that sounds more like something that gets the parent hir id => `hir::Map::parent_id`. Same with `find_parent_node` => `opt_parent_id`.

Also, combine `hir.get(hir.parent_id(hir_id))` and similar `hir.find(hir.parent_id(hir_id))` function into new functions that actually retrieve the parent node in one call. This last commit is the only one that might need to be looked at closely.
@compiler-errors
Copy link
Member Author

This is bitrotty

@bors p=1

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 5, 2023
…mpiler-errors

Rollup of 6 pull requests

Successful merges:

 - rust-lang#105846 (Account for return-position `impl Trait` in trait in `opt_suggest_box_span`)
 - rust-lang#106385 (Split `-Zchalk` flag into `-Ztrait-solver=(classic|chalk|next)` flag)
 - rust-lang#106403 (Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`)
 - rust-lang#106462 (rustdoc: remove unnecessary wrapper around sidebar and mobile logos)
 - rust-lang#106464 (Update Fuchsia walkthrough with new configs)
 - rust-lang#106478 (Tweak wording of fn call with wrong number of args)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Collaborator

bors commented Jan 5, 2023

⌛ Testing commit b1b19bd with merge 1429899...

@bors bors merged commit 5ce6311 into rust-lang:master Jan 5, 2023
@rustbot rustbot added this to the 1.68.0 milestone Jan 5, 2023
@compiler-errors compiler-errors deleted the rename-hir-methods branch August 11, 2023 20:14
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. 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.

7 participants