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

Simplify resolve_lifetimes #57408

Closed
wants to merge 4 commits into from

Conversation

ljedrz
Copy link
Contributor

@ljedrz ljedrz commented Jan 7, 2019

Obtaining hir_id is free during lowering, so I thought it might be a good idea to save it while creating hir::Lifetime and hir::GenericParam so that resolve_lifetimes can do less work.

I'm pretty sure resolve_lifetimes can be simplified further (I'd like to squash NamedRegionMap with ResolveLifetimes), but I need to sleep on it; this seems like a step in the right direction.

As an added bonus this should be a step forward for #50928.

r? @varkor

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 7, 2019
src/librustc/hir/lowering.rs Outdated Show resolved Hide resolved
@rust-highfive

This comment has been minimized.

src/librustc/hir/lowering.rs Outdated Show resolved Hide resolved
@@ -538,6 +539,7 @@ pub enum GenericParamKind {
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct GenericParam {
pub id: NodeId,
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid having NodeId at all? Then this would be a clear win. Have you looked at the remaining uses of id for GenericParam and Lifetime?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have, and there were quite a few. I can try giving it a shot 👍.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@varkor Actually this is super complex; NodeId is still used in lots of places and just removing it causes lots of breakage, making it hard to debug. I can see that most Hir objects still point to NodeId, probably for the same reason. I have a suggestion: I will try to migrate methods working on NodeId to HirId in following PRs; at one point the compiler should just tell us that the NodeId field is not used anymore - that approach should be a lot cleaner.

@ljedrz
Copy link
Contributor Author

ljedrz commented Jan 9, 2019

Do you think the extra memory required to hold hir_id would be noticeable in the perf? Maybe it's not a big deal; otherwise, of course, some other way of cracking this would be advisable.

@ljedrz
Copy link
Contributor Author

ljedrz commented Jan 11, 2019

FWIW, in the meantime I'm trying to go HARD (the only way possible tbh) on HirIdification; if I succeed, most of the NodeIds in Hir items should become obsolete.

@ljedrz
Copy link
Contributor Author

ljedrz commented Jan 13, 2019

Closing in favor of #57578.

@ljedrz ljedrz closed this Jan 13, 2019
@ljedrz ljedrz deleted the simplify_resolve_lifetimes branch March 9, 2019 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants