rust-lang / rust-lang/rust-analyzer

How to prevent rust-analyzer importing duplicate or wrong items?

Open
#17,132 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,

I'm using rust-analyzer in neovim (lunarvim) and it works almost fine.
But in some cases when I already have some imported struct or enum from my own crates or libs ( for example customized Result or Error ) rust-analyzer auto completion adds unwanted and duplicated struct or enum from other cartes like serde or std.

every time it happens I face unexpected error in my file and when I check on top of my file I find some unexpected use lines added there.

Sometime it is really annoying as it repeads several times during editing code.

So please help me find how I can prevent rust-analyzer from this action or at least prevent duplicate same name import?

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 issue in rust-analyzer through Neovim or LunarVim with custom Result or Error types and completion enabled. Check when completion adds unexpected or duplicate use lines from serde or std; done means the reproduction is explained and a way to prevent the unwanted imports or duplicates is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
neovim, rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.