Description
Here are two slightly different sources with slightly different errors:
use foo;
fn main() { }
error[E0432]: unresolved import `foo`
--> src/main.rs:1:5
|
1 | use foo;
| ^^^ no `foo` external crate
use foo::bar;
fn main() { }
error[E0432]: unresolved import `foo`
--> src/main.rs:1:5
|
1 | use foo::bar;
| ^^^ use of undeclared type or module `foo`
For use foo
, the error is "no foo external crate"; for use foo::bar
it is "undeclared type or module foo".
The first error I think is unambiguously correct - there's nothing foo could be but an external crate. The second though is failing to mention that foo could very will be a missing crate. And it may be more likely to be a missing crate (or a typo...) than a type or module that hasn't been imported.
I encountered this second error while writing some training material and had to explain that the error is misleading and that actually you need to list crate foo in your manifest.
A better error might be "use of undeclared crate, type, or module" (while also changing the first one to "use of undeclared crate" for consistency), or "no foo extern crate, or use of undeclared type or module foo". Even better might be to do some analysis to see if there is any crate with a name close to "foo", whether there are any internal names equal to or similar to "foo", and customize the error based on that.
This is using whatever nightly is current right now.