Skip to content
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

Factor out several utils, add path_def_id #8305

Merged
merged 10 commits into from
Feb 7, 2022

Conversation

camsteffen
Copy link
Contributor

changelog: none

This is generally an effort to reduce the total number of utils. path_def_id is added which I believe is more "cross-cutting" and also complements path_to_local. Best reviewed one commit at a time.

Added:

  • path_def_id
  • path_res

Removed:

  • is_qpath_def_path
  • match_any_diagnostic_items
  • expr_path_res
  • single_segment_path
  • differing_macro_contexts
  • is_ty_param_lang_item
  • is_ty_param_diagnostic_item
  • get_qpath_generics

Renamed:

  • path_to_res to def_path_res
  • get_qpath_generic_tys to qpath_generic_tys

CC @Jarcho since this relates to some of your work and you may have input.

@rust-highfive
Copy link

r? @giraffate

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 17, 2022
@camsteffen camsteffen changed the title Factor out several utils Factor out several utils, add path_def_id Jan 17, 2022
@Jarcho
Copy link
Contributor

Jarcho commented Jan 18, 2022

The only thing I would question here is how much utility path_def_id really gives over just having path_res. It's only slightly shorter and does the obvious thing (it's 10 characters shorter).

Other than that I think this is good. It's an improvement over what currently exists and no matter what changes happen afterwards related to identifying items, paths will need to be resolved. Having all path resolution go through the same place will probably make future changes easier.

@camsteffen
Copy link
Contributor Author

Yeah path_res(expr).opt_def_id() isn't bad. I was thinking that path_def_id is so widely applicable that it's worth it but now I'm not so sure.

Also is the distinction between def_path_res and path_res good enough? path_res should be much more widely used so the short name is nice. But it could be path_node_res...liking that as I type it.

@camsteffen camsteffen added S-needs-discussion Status: Needs further discussion before merging or work can be started and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jan 18, 2022
@Jarcho
Copy link
Contributor

Jarcho commented Jan 20, 2022

def_path_res should be rare enough that it isn't that big of a deal. Could name it resolve_def_path as it's actually resolving the path and not just looking up what the given path resolves to.

path_node_res sounds fine.

@bors
Copy link
Contributor

bors commented Jan 21, 2022

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

@camsteffen camsteffen removed the S-needs-discussion Status: Needs further discussion before merging or work can be started label Jan 28, 2022
@camsteffen
Copy link
Contributor Author

Rebased. I searched the code for opt_def_id() and we really do that a lot so I think path_def_id is worth it (again). I also figured adding _node doesn't ultimately add much clarity. 🤷

Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

This looks like a great simplification of our utils!

Regarding the naming, I'm fine with how it is now. But I'll leave that decision up to you @Jarcho & @camsteffen.

r=me if you settled on the naming of the functions.

@Jarcho
Copy link
Contributor

Jarcho commented Feb 7, 2022

I think the name is fine as is. One small quip here is it doesn't actually take a Path or QPath despite what the name might lead one to believe. Not really an issue though.

@camsteffen
Copy link
Contributor Author

@bors r=flip1995

@bors
Copy link
Contributor

bors commented Feb 7, 2022

📌 Commit bd583d9 has been approved by flip1995

@bors
Copy link
Contributor

bors commented Feb 7, 2022

⌛ Testing commit bd583d9 with merge 3d43826...

@bors
Copy link
Contributor

bors commented Feb 7, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 3d43826 to master...

@bors bors merged commit 3d43826 into rust-lang:master Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants