Ambiguous module files report unrelated errors
When there is a module name collision, rust-analyzer reports unrelated errors making it hard for the user to understand what is going on. I believe this is what we see on #19709.
A reproducible test case is available in https://github.com/stephanemagnenat/ra-ghost-module, the related Zed issue that surfaced this situation in the first place is reported here: zed-industries/zed#64231.
It could be good if rust-analyzer would report a clear user message like the Rust compiler do:
error[E0761]: file for module `ast` found at both "src/ast.rs" and "src/ast/mod.rs"
--> src/lib.rs:1:1
|
1 | mod ast;
| ^^^^^^^^
|
= help: delete or rename one of them to remove the ambiguityinstead of the current behaviour when errors related to common std types appear instead.
This issue is a follow up of issue #23366 but focusing on the error message reporting, which is the real problem here.
rust-analyzer version: 0.3.3049-standalone (release 2026-09-14, commit https://github.com/rust-lang/rust-analyzer/commit/682a84e95b5a52cf06e9822fcaa4f628738554bf) rustc version: 1.98.0 (88d9e12ae 2026-08-18) editor or extension: Zed 1.19.2 (df181c6f58d0)
Source: rust-lang/rust-analyzer