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: Renaming both struct and function with the same name #19306

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

asuto15
Copy link
Contributor

@asuto15 asuto15 commented Mar 6, 2025

fixes #18892.

Note

Although the original issue did not specify whether to rename both definitions or only one, since the original code exports both under the same name, it is preferable for rust-analyzer’s behavior to rename both.
This implementation therefore renames both the struct and the function, ensuring consistency.

Important

This implementation is limited to handling struct/function pairs. It does not cover other combinations (e.g. enum variants with associated functions, constants paired with functions, or trait methods).
If needed, separate issues should be created to address those other cases individually.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 6, 2025
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.

This seems like the wrong way to tackle this. Specifically we need to verify that the references we want to change are not ambigious, and in the case they are, disambiguate them. That is for imports at least, we need to split out the ambigious import into something unambigious (so for example instead of changing the identifier, just add an import for the new name). This probably requires our semantics path resolver to be namespace aware which is a still a big task that has to be done in general. So this might not be that actionable yet

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.

Renaming a struct that has a function with the same name will break code:
3 participants