rust-lang / rust-lang/rust-analyzer
Feature request: Improve import assist by considering types
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Today I (re)wrote some code like this:
match channel_sender.try_send(value) {
Err(TrySendError::Full(_)) => todo!(),
// ...
}
And used Ctrl+. to import TrySendError. There were multiple choices due to dependencies on all of std, tokio and async-channel. It would have been nice to not have to navigate the Import TrySendError sub-menu where I had to choose between the various available types, since RA correctly figured out that try_send is from tokio and returns Result<(), tokio::sync::mpsc::error::TrySendError<T>>.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Ctrl+. import-assist flow with the shown tokio try_send example and inspect how the available TrySendError candidates are presented. Use the inferred return type to determine when one import is unambiguous; done means the tokio type is selected without the submenu while valid alternatives remain available when the type is not decisive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100