rust-lang / rust-lang/rust-analyzer

Feature request: Improve import assist by considering types

Open
#10,471 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-assists C-feature S-actionable
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.