Closed
Description
Code
use some_novel_crate::Type;
fn main() {
println!("{}", Type::new());
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0432]: unresolved import `some_novel_crate`
--> src/main.rs:1:5
|
1 | use some_novel_crate::Type;
| ^^^^^^^^^^^^^^^^ use of undeclared crate or module `some_novel_crate`
For more information about this error, try `rustc --explain E0432`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Desired output
Compiling playground v0.0.1 (/playground)
error[E0432]: unresolved import `some_novel_crate`
--> src/main.rs:1:5
|
1 | use some_novel_crate::Type;
- | ^^^^^^^^^^^^^^^^ use of undeclared crate or module `some_novel_crate`
+ | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate`
For more information about this error, try `rustc --explain E0432`.
+help: Consider using `cargo add some_novel_crate` to add the crate to your Cargo.toml
+help: Consider defining a module: `mod some_novel_crate { }`
error: could not compile `playground` (bin "playground") due to 1 previous error
Rationale and extra context
playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=a60453f1bdbe2f05f3e1d05560f189f5
If we want people to actually learn the language's finer points, we need to be careful to not casually hack apart the mental model by misusing our own terminology. There is clearly a declaration right there, so saying it is undeclared is misleading at best, actively harmful to understanding at worst: https://doc.rust-lang.org/reference/items/use-declarations.html
Further, a resolution error failing to turn up a module is solved in a very different way, from a user perspective, from a crate not being resolved.
Other cases
Rust Version
rustc 1.84.0-nightly (f2a35426b 2024-11-16)
binary: rustc
commit-hash: f2a35426b6586178c44b27cedae182502092e898
commit-date: 2024-11-16
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsDiagnostics: Confusing error or lint that should be reworked.Diagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.