Too many errors for missing crate for nested imports and later uses of crate
Open
@yuk1ty is already working on this.
Since Mar 14, 2026.
A-diagnostics
D-verbose
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
use foo::{bar, baz::bat};
pub fn main() {
foo::qux();
}
Current output
error[E0433]: cannot find module or crate `foo` in this scope
--> src/main.rs:1:5
|
1 | use foo::{bar, baz::bat};
| ^^^ use of unresolved module or unlinked crate `foo`
|
= help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml`
error[E0432]: unresolved import `foo`
--> src/main.rs:1:5
|
1 | use foo::{bar, baz::bat};
| ^^^ use of unresolved module or unlinked crate `foo`
|
= help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml`
error[E0433]: cannot find module or crate `foo` in this scope
--> src/main.rs:3:5
|
3 | foo::qux();
| ^^^ use of unresolved module or unlinked crate `foo`
|
= help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml`
Desired output
error[E0432]: unresolved import `foo`
--> src/main.rs:1:5
|
1 | use foo::{bar, baz::bat};
| ^^^ use of unresolved module or unlinked crate `foo`
|
= help: if you wanted to use a crate named `foo`, use `cargo add foo` to add it to your `Cargo.toml`
Rationale and extra context
Either one of the first two errors would be fine, both at the same time are redundant.
The third error is more acceptable, but ideally we wouldn't emit it. Potentially, it might make sense to have a single error pointing at line 1 and line 3, but we can "just" silence the third error after the prior import error (like we already do if we write use foo;). This would make it so that a fixing a typo in the import would then suddenly trigger later errors in places where the typo also needed to be fixed, but that should be ok.
Other cases
Rust Version
1.93 and 1.95 nightly
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.