rust-lang / rust-lang/rust-analyzer

Rust hover shows `mod draw` for `use super::draw` that resolves to function

Open
#22,632 4 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

code:

mod outer {
    // This is the function that `super::draw` should resolve to.
    pub fn draw(_: i32) {}

    mod inner {
        use super::draw;

        pub fn test() {
            draw(1);
        }
    }
}

// This module has the same name, but it is not the target of `super::draw`.
mod draw {}

explanation:

Expected: hover on draw in use super::draw shows the function outer::draw. Actual: hover shows mod draw. Go to definition resolves correctly.

I'm not sure whether this is a Zed issue or a rust-analyzer issue, but the hover information looks inconsistent with go-to-definition.

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 reproducing the hover and go-to-definition behavior with the Rust snippet in the issue, focusing on use super::draw inside outer::inner. Trace the hover resolution path and compare it with the definition-resolution result; done when hover identifies outer::draw rather than the unrelated draw module.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.