rust-lang / rust-lang/rust-analyzer

auto-import sometimes breaks with `self` imports

Open
#20,790 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

rust-analyzer version: 1.90.0 (1159e78 2025-09-14), 1.92.0-nightly (5c7ae0c 2025-10-02)

rustc version: 1.90.0 (1159e78c4 2025-09-14), 1.92.0-nightly (5c7ae0c7e 2025-10-02)

editor or extension: Zed

relevant settings: none, as far as I can tell

repository link: https://github.com/generic-daw/generic-daw

instructions to reproduce:

  1. clone above repo
  2. disable nightly-only features present in .rustfmt.toml (not strictly necessary, this reproduces without)
  3. navigate to https://github.com/generic-daw/generic-daw/blob/716331b78cec8fad10f8e09dbf92eb4ad76beae8/generic_daw_gui/src/arrangement_view.rs#L984
  4. remove the text:: prefix of text::Wrapping::None
  5. auto-import Wrapping from iced::widget::text::Wrapping
  6. observe that the import has been changed to text::{self, Wrapping}, and that all calls to the text function have broken

I'm sadly not sure how to minimize this, I've just encountered this specific case a bunch in this project and only just noticed that the aforementioned nightly-only rustfmt options aren't to blame.

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 generic_daw_gui/src/arrangement_view.rs around the reported line by removing the text:: prefix and invoking auto-import for iced::widget::text::Wrapping. Start by examining the generated text::{self, Wrapping} import and its effect on text function calls; done means auto-import preserves those calls, with a regression test for this case.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.