rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.32k stars 1.61k forks source link

Test function imports replaced by module imports. #18464

Open rwakulszowa opened 2 weeks ago

rwakulszowa commented 2 weeks ago

Test for #18347. The issue affects all code using import merging. When a function and a module share the same identifier, e.g.

pub fn foo() {}
pub mod foo { pub fn bar() {} }

rust analyzer often confuses the function with the module, generating invalid code.

rwakulszowa commented 2 weeks ago

I haven't been able to actually find a proper fix yet. I can't find a reliable way to tell the merging function whether an import is a module (and can be used for merging) or a function.

I'm not sure if I manage to find a solution, so I'm sending a small PR with what I have.