Skip to content

Hover returns info about wrong item, when multiple items with the same name imported #19813

Open
@A-Walrus

Description

@A-Walrus

rust-analyzer version: rust-analyzer 1.86.0 (05f9846 2025-03-31)

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

editor or extension: Helix

repository link (if public, optional): (eg. rust-analyzer)

code snippet to reproduce:

[package]
name = "rust-analyzer-bug"
version = "0.1.0"
edition = "2024"

[dependencies]
svg = "0.18.0"
use svg::node::element::Path;

use svg::node::element::tag::Path;
use svg::parser::Event;

fn main() {
    let a = Path;
    let mut content = String::new();

    for event in svg::open("whatever.svg", &mut content).unwrap() {
        match event {
            Event::Tag(Path, _, _) => {
                println!("This is a path")
            }
            _ => {}
        }
    }
}

Hitting hover on the Path in Event::Tag returns info about the element::Path (a struct) and not about tag::Path (a const &'static str). Doing it on the Path in let a = ... correctly shows the tag version.

Recording showing the issue
https://asciinema.org/a/Aolx1UaOxaINhDinOvVXwl905

P.S. Obviously it's very bad practice to import multiple things with the same name, but in this case the compiler allows it and the code builds and runs, so we should have correct hover info

Activity

Hmikihiro

Hmikihiro commented on Jun 27, 2025

@Hmikihiro
Contributor

small sample code

struct Tag(&'static str);
struct Path {}

const Path: &'static str = "sample";
fn main() {
    match Tag(Path /*const Path: &'static str*/) {
        Tag(Path /* struct Path {} */) => {}
        _ => {}
    }
}
linked a pull request that will close this issue on Jun 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-idegeneral IDE featuresC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Veykril@Hmikihiro@A-Walrus

      Issue actions

        Hover returns info about wrong item, when multiple items with the same name imported · Issue #19813 · rust-lang/rust-analyzer