rust-lang / rust-lang/rust-analyzer

Flyimports (auto-imports) not working for modules

Open
#22,564 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

use declarations are not being automatically updated on selection of a module completion, even when the completion text includes (use ...). (additionalTextEdits is missing in the completionItem/resolve response.)

Reverting 379a1307aaf95736eecea8613ce3d408838d2ce8 (#22386) fixes this issue, but presumably the best fix would be something else.


rust-analyzer version: compiled locally from latest master (82f6a61ac038e327cfc655b2a6f0a309e6b5887c)

rustc version: rustc 1.95.0 (59807616e 2026-04-14)

editor or extension: Emacs (lsp-mode)

relevant settings: n/a

repository link (if public, optional): n/a

code snippet to reproduce:

fn main() {
  // Place cursor at the end of the next line, activate completion, and select the `std::os` completion. `use std::os;` should be inserted but is not.
  os
}

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 reviewing the completionItem/resolve behavior changed in commit 379a1307aaf95736eecea8613ce3d408838d2ce8 (#22386), focusing on why additionalTextEdits are absent. Reproduce the issue with the provided Rust snippet and verify that resolving the std::os completion returns the edit and inserts use std::os; when selected.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.