rust-lang / rust-lang/rust-analyzer

Import item suggestion should come before did-you-mean suggestion

Open
#11,862 6 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-assists A-diagnostics C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

I've hit this case a few times now: I do some regex-based mass renaming that only works for expressions, not imports, then manually clean up the old broken import and want to import the new thing using the import suggstion whereever a new name needs importing.

This usually works fine, until there is an item already in scope with a similar name to what I need to import. My muscle memory then sometimes leads me to apply the first suggestion of "there's a thing with a similar name in scope, did you mean that?" when that is not what I want.

I think when there is an exact match for an unresolved name, the suggestion to import it should be higher up in the list of suggestions than pretty much anything else.

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

Start by tracing rust-analyzer's completion suggestions for unresolved names, focusing on how import suggestions are ordered against did-you-mean suggestions. Reproduce the case with an exact import match and a similar in-scope item; done means the exact import suggestion appears first.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.