Error message for duplicate names suggests invalid Rust #45829
Closed
Description
Consider the following library (with hello
and aleph
externs provided):
extern crate hello;
extern crate aleph as hello;
rustc
will reasonably identify a problem:
error[E0259]: the name `hello` is defined multiple times
--> lib.rs:2:1
|
1 | extern crate hello;
| ------------------- previous import of the extern crate `hello` here
2 | extern crate aleph as hello;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `hello` reimported here
|
= note: `hello` must be defined only once in the type namespace of this module
but will then go on to suggest a rather unhelpful solution that isn't even valid Rust code:
help: You can use `as` to change the binding name of the import
|
2 | extern crate aleph as hello; as Otherhello
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^