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

fix: Resolve $crate in derive paths #14610

Merged
merged 2 commits into from
Apr 22, 2023

Conversation

lowr
Copy link
Contributor

@lowr lowr commented Apr 19, 2023

Paths in derive meta item list may contain any kind of paths, including those that start with $crate generated by macros. We need to take hygiene into account when we lower paths in the list.

This issue was identified while investigating #14607, though this patch doesn't fix the broken trait resolution.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 19, 2023
@lowr lowr force-pushed the fix/hygiene-for-meta-item branch from d6f184a to cf72b62 Compare April 20, 2023 06:50
@@ -1223,8 +1225,9 @@ impl DefCollector<'_> {
}
};
let ast_id = ast_id.with_value(ast_adt_id);
let hygiene = Hygiene::new(self.db.upcast(), file_id);
Copy link
Member

Choose a reason for hiding this comment

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

(Haven't checked) I feel like we should have a hygiene lying around here somewhere already no? (Building hygiene isn't the cheapest from what I remember)

Copy link
Contributor Author

@lowr lowr Apr 20, 2023

Choose a reason for hiding this comment

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

All paths but those in attributes seem to be lowered during ItemTree construction, which is decoupled from DefCollector, so there's no Hygiene around here. Moreover, a single DefCollector operates on possibly multiple HirFileIds, so we can't just cache Hygiene in it.

One thing we could try is having something like HashMap<HirFileId, Hygiene> in DefCollector and building Hygiene on demand. How does that sound?

Copy link
Member

Choose a reason for hiding this comment

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

Ye I think adding that to reuse hygienes sounds good for now

@Veykril
Copy link
Member

Veykril commented Apr 22, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Apr 22, 2023

📌 Commit 85e7654 has been approved by Veykril

It is now in the queue for this repository.

@Veykril Veykril changed the title Resolve $crate in derive paths fix: Resolve $crate in derive paths Apr 22, 2023
@bors
Copy link
Contributor

bors commented Apr 22, 2023

⌛ Testing commit 85e7654 with merge 34ebb30...

@bors
Copy link
Contributor

bors commented Apr 22, 2023

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 34ebb30 to master...

@bors bors merged commit 34ebb30 into rust-lang:master Apr 22, 2023
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.

4 participants