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

HirIdification: kill off NodeId stragglers #59068

Merged
merged 5 commits into from
Mar 23, 2019

Conversation

ljedrz
Copy link
Contributor

@ljedrz ljedrz commented Mar 10, 2019

The final stages of HirIdification (#57578).

This PR, along with #59042, should finalize the HirIdification process (at least the more straightforward bits).

  • replace NodeId with HirId in trait_impls
  • remove all NodeIds from borrowck
  • remove all NodeIds from typeck
  • remove all NodeIds from mir
  • remove trait_auto_impl (unused)

I would be cool to also remove NodeId from hir::def::Def, middle::privacy::AccessLevel and hir::ItemId, but I don't know if this is feasible.

I'll be happy to do more if I've missed anything.

@rust-highfive
Copy link
Collaborator

r? @eddyb

(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 Mar 10, 2019
@ljedrz ljedrz changed the title ill off NodeId stragglers HirIdification: kill off NodeId stragglers Mar 10, 2019
@ljedrz
Copy link
Contributor Author

ljedrz commented Mar 10, 2019

r? @Zoxc

@rust-highfive rust-highfive assigned Zoxc and unassigned eddyb Mar 10, 2019
@Zoxc
Copy link
Contributor

Zoxc commented Mar 10, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Mar 10, 2019

📌 Commit 584d61a has been approved by Zoxc

@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 Mar 10, 2019
@Zoxc
Copy link
Contributor

Zoxc commented Mar 10, 2019

I would be cool to also remove NodeId from hir::def::Def, middle::privacy::AccessLevel and hir::ItemId, but I don't know if this is feasible.

Where do you get stuck on these?

@ljedrz
Copy link
Contributor Author

ljedrz commented Mar 11, 2019

With Def::Local and Def::Upvar (first component) everything is fine until rustc_resolve where they can (as far as I can tell) only be used with a NodeId. I haven't studied all the related code that much yet, but it looks as if they might be candidates for lowering; they are used in tandem with hir::Freevar which doesn't contain a HirId.

privacy::AccessLevel - issues with save_analysis.

ItemId - HashStable debug assertion for hir::Mod fails (probably error with id lowering).

I can give them another shot and send a WIP PR for further investigation.

@Zoxc
Copy link
Contributor

Zoxc commented Mar 11, 2019

@ljedrz For Def, I'd make it generic over the id used and have a type Def = def::Def<HirId> type alias for it.

Feel free to open PRs for the other ones.

@ljedrz
Copy link
Contributor Author

ljedrz commented Mar 12, 2019

I've tried the generic Def approach, but it quickly becomes quite messy (especially before the stable hash derive macro goes live); is an enum containing either NodeId or HirId out of the question (though I haven't attempted that yet - it might get messy too)?

@Zoxc
Copy link
Contributor

Zoxc commented Mar 12, 2019

I've tried the generic Def approach, but it quickly becomes quite messy

What do you mean by messy?

(especially before the stable hash derive macro goes live)

That will land soon at least.

@ljedrz
Copy link
Contributor Author

ljedrz commented Mar 12, 2019

What do you mean by messy?

There are other objects containing Def and they also need to become generic and often additionally have some of the bounds applicable to NodeId and HirId like Debug and Display.

@eddyb
Copy link
Member

eddyb commented Mar 13, 2019

There are other objects containing Def and they also need to become generic

How so? I suspect that you can partition most of them into "used during/produced by rustc_resolve" (Def<NodeId>) and "contained in the HIR/elsewhere" (Def<HirId>).

As an aside, I should reiterate that the Def type should be named Res or something (since it's the result of name resolution, which is not exactly "definition" in same sense as DefId)

Also, things could be slightly nicer by having the HIR represent uses of local variables (including upvars) as a separate ExprKind variant (instead of Path), but that might not be a trivial refactoring right now.

@ljedrz
Copy link
Contributor Author

ljedrz commented Mar 13, 2019

Hmm, I guess I can give it another shot as soon as #56864 lands 👍.

@mark-i-m
Copy link
Member

mark-i-m commented Mar 13, 2019

#56864 has already landed?

EDIT: ah, it landed 3 hours after your post 😛

Centril added a commit to Centril/rust that referenced this pull request Mar 16, 2019
…r=Zoxc

HirIdification: kill off NodeId stragglers

The final stages of HirIdification (rust-lang#57578).

This PR, along with rust-lang#59042, should finalize the HirIdification process (at least the more straightforward bits).

- replace `NodeId` with `HirId` in `trait_impls`
- remove all `NodeId`s from `borrowck`
- remove all `NodeId`s from `typeck`
- remove all `NodeId`s from `mir`
- remove `trait_auto_impl` (unused)

I would be cool to also remove `NodeId` from `hir::def::Def`, `middle::privacy::AccessLevel`  and `hir::ItemId`, but I don't know if this is feasible.

I'll be happy to do more if I've missed anything.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Mar 22, 2019
…r=Zoxc

HirIdification: kill off NodeId stragglers

The final stages of HirIdification (rust-lang#57578).

This PR, along with rust-lang#59042, should finalize the HirIdification process (at least the more straightforward bits).

- replace `NodeId` with `HirId` in `trait_impls`
- remove all `NodeId`s from `borrowck`
- remove all `NodeId`s from `typeck`
- remove all `NodeId`s from `mir`
- remove `trait_auto_impl` (unused)

I would be cool to also remove `NodeId` from `hir::def::Def`, `middle::privacy::AccessLevel`  and `hir::ItemId`, but I don't know if this is feasible.

I'll be happy to do more if I've missed anything.
@bors
Copy link
Contributor

bors commented Mar 23, 2019

⌛ Testing commit 584d61a with merge c3182db4e8af03d6af9504e6a5389d1d4f4e861c...

@bors
Copy link
Contributor

bors commented Mar 23, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: Zoxc
Pushing c3182db4e8af03d6af9504e6a5389d1d4f4e861c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 23, 2019
@bors
Copy link
Contributor

bors commented Mar 23, 2019

👀 Test was successful, but fast-forwarding failed: 422 Update is not a fast forward

@Zoxc
Copy link
Contributor

Zoxc commented Mar 23, 2019

@bors retry

@bors
Copy link
Contributor

bors commented Mar 23, 2019

⌛ Testing commit 584d61a with merge 0633c55...

bors added a commit that referenced this pull request Mar 23, 2019
HirIdification: kill off NodeId stragglers

The final stages of HirIdification (#57578).

This PR, along with #59042, should finalize the HirIdification process (at least the more straightforward bits).

- replace `NodeId` with `HirId` in `trait_impls`
- remove all `NodeId`s from `borrowck`
- remove all `NodeId`s from `typeck`
- remove all `NodeId`s from `mir`
- remove `trait_auto_impl` (unused)

I would be cool to also remove `NodeId` from `hir::def::Def`, `middle::privacy::AccessLevel`  and `hir::ItemId`, but I don't know if this is feasible.

I'll be happy to do more if I've missed anything.
@bors
Copy link
Contributor

bors commented Mar 23, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: Zoxc
Pushing 0633c55 to master...

@bors bors merged commit 584d61a into rust-lang:master Mar 23, 2019
@ljedrz ljedrz deleted the kill_off_NodeId_stragglers branch March 24, 2019 05:24
@Zoxc
Copy link
Contributor

Zoxc commented Apr 2, 2019

@ljedrz Did you try dealing with Def or should I take a shot at it?

@ljedrz
Copy link
Contributor Author

ljedrz commented Apr 3, 2019

@Zoxc I've started, but I'm traveling this week, so I might not be able to resume until the next one; if you'd prefer this to be done more quickly you can use my branch that should have most of the HIR-and-above-side changes; what's left is splitting Def (or Res) into the HIR and resolver objects.

@Zoxc
Copy link
Contributor

Zoxc commented Apr 4, 2019

@ljedrz I made some progress in https://github.com/Zoxc/rust/tree/hiridify_def_id, but I run into issues lowering Defs with node ids that have yet to be lowered.

@eddyb
Copy link
Member

eddyb commented Apr 4, 2019

@Zoxc Can't you allocate the NodeId -> HirId at the first use, and have the latter lowering of the actual node in question reuse the same HirId?

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