Description
Given the code in file user.rs
as shown below:
use a_great_crate::item;
rustc outputs the following when invoked via rustc user.rs --crate-type=lib --edition=2021 --extern=a-great-crate=liba_great_crate.rlib
:
error[E0432]: unresolved import `a_great_crate`
--> user.rs:1:5
|
1 | use a_great_crate::item;
| ^^^^^^^^^^^^^ use of undeclared crate or module `a_great_crate`
|
help: there is a crate or module with a similar name
|
1 | use a-great-crate::item;
| ~~~~~~~~~~~~~
error: aborting due to previous error
For more information about this error, try `rustc --explain E0432`.
While ideally, in this specific case it should either suggest nothing of if feasible suggest changing the --extern
flag to --extern=a_great_crate=liba_great_crate.rlib
(the latter is probably P-low). I did actually get confused by the suggestion when I originally faced it.
In fact, rustc suggests whatever garbage you put in the flag (e.g. on rustc … '--extern=a&-gre?t#crate=xxx'
). In these cases it shouldn't consider the name at all (I realize though that this might be a case of garbage in, garbage out).
@rustbot label T-compiler A-diagnostics A-suggestion-diagnostics D-invalid-suggestion