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 alias renaming usage #13500

Closed
wants to merge 1 commit into from

Conversation

Bben01
Copy link
Contributor

@Bben01 Bben01 commented Oct 27, 2022

Close #13498

@Bben01
Copy link
Contributor Author

Bben01 commented Oct 27, 2022

I tried to fix it the same way #9148 did, just on a lower level

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

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

Heh, this is actually a fun issue. So the problem here is more that the original name is a prefix of the alias name, which makes our search do wrong things. The correct place to fix this is not in the renaming code actually, but in the search part.

We should instead check here https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-db/src/search.rs#L460-L468
if the name like we found has the same text as the name we are looking for. Due to find_nodes_at_offset_with_descend returning the macro expanded result this token may differ, so we need to do the filtering before, we can probably do this by doing what find_nodes_at_offset_with_descend manually, the relevant parts being https://github.com/rust-lang/rust-analyzer/blob/master/crates/hir/src/semantics.rs#L926-L943

This turns the fix into something more complex unfortunately, if you don't feel like doing this that's obviously fine, if you want to tackle it and have questions feel free to ask.

@Veykril Veykril added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 3, 2022
@Veykril
Copy link
Member

Veykril commented Nov 5, 2022

Put up #13549 to fix it as this causes more problems than just renaming

@Veykril Veykril closed this Nov 5, 2022
@Bben01 Bben01 deleted the bugfix/fix-alias-renaming branch November 5, 2022 19:32
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.

Renaming struct renames usage even if aliased
2 participants