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

Replace HIR's ItemId structs with aliases #67999

Closed
wants to merge 4 commits into from

Conversation

ljedrz
Copy link
Contributor

@ljedrz ljedrz commented Jan 8, 2020

I'm not 100% sure this is a valid approach (and if not, then perhaps all 3 could be merged into a single ItemId), but it passes the tests locally.

It appears that we can "downgrade" HIR's ImplItemId, ItemId and TraitItemId to just aliases of HirId which is a cleanup on its own and opens up further cleanup opportunities.

r? @varkor

@Dylan-DPC-zz Dylan-DPC-zz added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 8, 2020
@Centril
Copy link
Contributor

Centril commented Jan 8, 2020

cc @Zoxc

// the HIR, since they just signify a HIR nodes own path. But `ItemId` et al
// are used when another item in the HIR is *referenced* and we certainly
// want to pick up on a reference changing its target, so we hash the NodeIds
// in "DefPath Mode".
Copy link
Contributor

Choose a reason for hiding this comment

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

These types do have different impls than HirId. Why can this now be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seeing that comment I thought about how much the NodeIds have become deprecated after the lowering and wondered if we could get away with it. If there's a reason we should stick to this solution, though, we can probably still merge all these 3 types into 1, because their impls are identical.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think we should either merge them, or keep them separate if there's a good reason for them to remain separate. I'm not confident about the reason for their being separate in the first place, though, so I'd prefer if someone else clarified this.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Merging the 3 types into 1 should be fine. Using an alias would be a change in semantics, leading to things being ignored during hashing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any suggestion on the name? Would ItemId be fine?

@bors
Copy link
Contributor

bors commented Jan 9, 2020

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

@JohnCSimon JohnCSimon 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 18, 2020
@JohnCSimon
Copy link
Member

Ping from triage: @ljedrz can you please address the merge conflicts?

@JohnCSimon
Copy link
Member

Pinging again from triage: @ljedrz can you please address the merge conflicts?

@ljedrz
Copy link
Contributor Author

ljedrz commented Jan 25, 2020

@JohnCSimon I'm still waiting for further instructions from the compiler team; see varkor's comment.

@michaelwoerister
Copy link
Member

I actually don't think this change is an improvement. New-typing things in order to avoid accidental mixups is a common technique for avoiding bugs. I personally would leave the types as they are unless there is a strong reason to change them.

You could collapse the hash_item_id(), hash_impl_item_id(), and hash_trait_item_id() methods into a single hash_reference_to_item() method if you want to reduce code duplication.

@ljedrz
Copy link
Contributor Author

ljedrz commented Feb 5, 2020

Closing in favor of #68858.

@ljedrz ljedrz closed this Feb 5, 2020
@ljedrz ljedrz deleted the remove_trait_impl_id_structs branch February 5, 2020 10:16
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 5, 2020
…=michaelwoerister

Merge item id stable hashing functions

Supersedes rust-lang#67999 splitting out the pure cleanup bits, i.e. merging `hash_item_id`, `hash_impl_item_id` and `hash_trait_item_id` into a common `hash_reference_to_item`.

r? @michaelwoerister
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants