Skip to content

fix: auto-complete import for aliased function and module #18382

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

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

dqkqd
Copy link
Contributor

@dqkqd dqkqd commented Oct 23, 2024

Close #17042

Get the aliased name from import_path to use for import instead of name defined inside local module.

image

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 23, 2024
// Use the last segment when `item_to_import` matches `original_item`,
// as it will take the aliased name into account.
let local_name = if import_edit.item_to_import == import_edit.original_item {
import_edit.import_path.segments().last()?.clone()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this is a right way to get the aliased name.

Copy link
Member

Choose a reason for hiding this comment

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

It is a decent workaround for the core issue I mentioned for now I think, could put a FIXME comment mentioning #14079 as the proper fix for this above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the FIXME.
There was a similar case with completion in pattern as well, so I added a testcase with the same fix.

@Veykril
Copy link
Member

Veykril commented Oct 24, 2024

So, the root issue is due to #14079, basically we should be treating imports as their own items to refer to. I'd need to look into that issue again to tell where we are with it (iirc only the IDE integration is missing, but that is still quite a bit to work on)

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.

Thanks!

@Veykril Veykril added this pull request to the merge queue Oct 30, 2024
Merged via the queue into rust-lang:master with commit 223979b Oct 30, 2024
9 checks passed
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.

Public re-exports do not appear in code completion
3 participants