rust-lang / rust-lang/rust-analyzer

Incorrect import/qualify fixits for re-exported (and renamed) paths

Open
#19,776 0 comments 0 reactions 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: 0.4.2454-standalone (8b624868e4 2025-05-08)

rustc version: rustc 1.86.0 (05f9846f8 2025-03-31)

editor or extension: VSCode (extension: 0.4.2454)

relevant settings: n/a

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

code snippet to reproduce:

mod foo {
    #[derive(Default)]
    pub struct Foo;
}

mod bar {
    pub use super::foo::Foo as Bar;
}

fn main() {
    let _: Bar = Default::default();
    //      ^ open quick fix with cursor at this token
}

When opening "quick fix" for Bar you get this:

Quick Fix
Import foo::Foo
Qualify as foo::Foo

… whereas you should instead get this:

Quick Fix
Import bar::Bar
Qualify as bar::Bar

… since the former produces broken code, when applied.

The issue seems to be reproducible for all missing imports of paths that were themselves re-exported under a different name further down the line.

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 with the minimal Rust reproduction in the issue and inspect how rust-analyzer generates import and qualification quick fixes for the unresolved Bar path. Verify the fix by checking that both offered actions use bar::Bar and produce valid code when applied.

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
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.