Misleading use foo::bar
error message
#61942
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-resolve
Area: Name/path resolution done by `rustc_resolve` specifically
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Here are two slightly different sources with slightly different errors:
For
use foo
, the error is "no foo external crate"; foruse 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.
The text was updated successfully, but these errors were encountered: