Skip to content

Auto import unresolved module and constant value with similarly name #19816

Open
@A4-Tacks

Description

@A4-Tacks
Contributor

rust-analyzer version: rust-analyzer 1.88.0-nightly (a15cce2 2025-04-17)

rustc version: rustc 1.88.0-nightly (a15cce269 2025-04-17)

editor or extension: VIM9.1 coc-rust-analyzer

code snippet to reproduce:

mod foo {
    pub mod bar {
        pub fn baz() {}
    }
    pub fn bar() {}
}
use foo::bar;

fn main() {
    let _ = bar();
    baz
}

On line 11 complete baz:

mod foo {
    pub mod bar {
        pub fn baz() {}
    }
    pub fn bar() {}
}
use foo::bar::{self, baz};

fn main() {
    let _ = bar();
    baz();
}

rustc: error[E0423]: expected function, found module `bar`

Expect:

mod foo {
    pub mod bar {
        pub fn baz() {}
    }
    pub fn bar() {}
}
use foo::{bar, bar::baz};

fn main() {
    let _ = bar();
    baz();
}

Activity

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

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @A4-Tacks

        Issue actions

          Auto import unresolved module and constant value with similarly name · Issue #19816 · rust-lang/rust-analyzer