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

librustc_hir: return LocalDefId instead of DefId in local_def_id #70909

Merged

Conversation

marmeladema
Copy link
Contributor

@marmeladema marmeladema commented Apr 7, 2020

Its a first try to remove a few calls to expect_local and use LocalDefId instead of DefId where possible for #70853

This adds some calls to .to_def_id() to get a DefId back when needed. I don't know if I should push LocalDefId even further and change, for example, Res::Def to accept a LocalDefId instead of a DefId as second argument.

cc @ecstatic-morse

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @varkor (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 7, 2020
Comment on lines 1162 to 1176
maybe_unused_trait_imports: resolutions
.maybe_unused_trait_imports
.into_iter()
.map(|id| definitions.local_def_id(id))
.map(|id| definitions.local_def_id(id).to_def_id())
.collect(),
maybe_unused_extern_crates: resolutions
.maybe_unused_extern_crates
.into_iter()
.map(|(id, sp)| (definitions.local_def_id(id), sp))
.map(|(id, sp)| (definitions.local_def_id(id).to_def_id(), sp))
.collect(),
glob_map: resolutions
.glob_map
.into_iter()
.map(|(id, names)| (definitions.local_def_id(id), names))
.map(|(id, names)| (definitions.local_def_id(id).to_def_id(), names))
.collect(),
Copy link
Member

Choose a reason for hiding this comment

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

These maps likely should be switched to LocalDefId.

Copy link
Member

@eddyb eddyb left a comment

Choose a reason for hiding this comment

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

r=me modulo nit

@eddyb
Copy link
Member

eddyb commented Apr 8, 2020

@bors r+ rollup=never (unclear what perf impact this may have)

@bors
Copy link
Contributor

bors commented Apr 8, 2020

📌 Commit 6ae3888 has been approved by eddyb

@bors
Copy link
Contributor

bors commented Apr 8, 2020

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@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-review Status: Awaiting review from the assignee but also interested parties. labels Apr 8, 2020
@Dylan-DPC-zz
Copy link

@bors p=1

@varkor varkor assigned eddyb and unassigned varkor Apr 8, 2020
@bors
Copy link
Contributor

bors commented Apr 9, 2020

⌛ Testing commit 6ae3888 with merge 0c835b0...

@bors
Copy link
Contributor

bors commented Apr 10, 2020

☀️ Test successful - checks-azure
Approved by: eddyb
Pushing 0c835b0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 10, 2020
@bors bors merged commit 0c835b0 into rust-lang:master Apr 10, 2020
@eddyb
Copy link
Member

eddyb commented Apr 10, 2020

Performance impact looks neglibigle (I'm curious what will happen we start moving queries over).

@marmeladema marmeladema deleted the issue70853/librustc_hir-local-def-id branch April 10, 2020 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants