5

fix: Resolve `$crate` in derive paths by lowr · Pull Request #14610 · rust-lang/...

 1 year ago
source link: https://github.com/rust-lang/rust-analyzer/pull/14610
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Contributor

@lowr lowr

commented

Apr 19, 2023

edited

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.

lnicola reacted with heart emoji

rustbot

added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label

Apr 19, 2023

@@ -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);

(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)

Contributor

Author

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?

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

Member

@bors r+

Collaborator

pushpin Commit 85e7654 has been approved by Veykril

It is now in the queue for this repository.

Veykril

changed the title Resolve $crate in derive paths

fix: Resolve $crate in derive paths

Apr 22, 2023

Collaborator

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

Collaborator

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

bors

merged commit 34ebb30 into

rust-lang:master

Apr 22, 2023

10 checks passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Veykril

Veykril left review comments
Assignees

No one assigned

Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

None yet

4 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK