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: ensure implied bounds from associated types are considered in autocomplete #17270

Merged

Conversation

davidbarsky
Copy link
Contributor

@davidbarsky davidbarsky commented May 21, 2024

closes: #16989

rust-analyzer needs to consider implied bounds from associated types in order to get all methods suggestions people expect. A pretty easy way to do that is to keep the candidate_trait_id's receiver if it matches TyFingerprint::Unnameable. When benchmarking this change, I didn't notice a meaningful difference in autocomplete latency.

(TyFingerprint::Unnameable corresponds to TyKind::AssociatedType, TyKind::OpaqueType, TyKind::FnDef, TyKind::Closure, TyKind::Coroutine, and TyKind::CoroutineWitness.)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 21, 2024
@davidbarsky davidbarsky requested a review from Veykril May 21, 2024 16:23
@davidbarsky davidbarsky force-pushed the david/fix-completions-from-associated-types branch from 3b34b97 to 2fef081 Compare May 21, 2024 17:27
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.

Would be good to add the reproduction as a test to crates\ide-completion\src\tests\special.rs or crates\ide-completion\src\tests\expression.rs

@Veykril
Copy link
Member

Veykril commented May 22, 2024

@bors delegate+

@bors
Copy link
Collaborator

bors commented May 22, 2024

✌️ @davidbarsky, you can now approve this pull request!

If @Veykril told you to "r=me" after making some further change, please make that change, then do @bors r=@Veykril

@davidbarsky davidbarsky force-pushed the david/fix-completions-from-associated-types branch from 2fef081 to f14d862 Compare May 22, 2024 19:52
@davidbarsky
Copy link
Contributor Author

Would be good to add the reproduction as a test to crates\ide-completion\src\tests\special.rs or crates\ide-completion\src\tests\expression.rs

Good point! I ended up adding a test in crates/ide-completion/src/tests/flyimport.rs instead because some of the other tests I wrote for this functionality were in that file.

@davidbarsky
Copy link
Contributor Author

@bors r=@Veykril

@bors
Copy link
Collaborator

bors commented May 22, 2024

📌 Commit f14d862 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented May 22, 2024

☔ The latest upstream changes (presumably #17252) made this pull request unmergeable. Please resolve the merge conflicts.

@davidbarsky davidbarsky force-pushed the david/fix-completions-from-associated-types branch from f14d862 to a0d3a81 Compare May 22, 2024 20:17
@davidbarsky
Copy link
Contributor Author

@bors retry

@davidbarsky
Copy link
Contributor Author

☔ The latest upstream changes (presumably #17252) made this pull request unmergeable. Please resolve the merge conflicts.

hoisted by my own petard!

@davidbarsky
Copy link
Contributor Author

@bors r=@Veykril

@bors
Copy link
Collaborator

bors commented May 22, 2024

📌 Commit a0d3a81 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented May 22, 2024

⌛ Testing commit a0d3a81 with merge 653b69e...

@bors
Copy link
Collaborator

bors commented May 22, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 653b69e to master...

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.

Import trait not suggested
4 participants