Skip to content

Error message for duplicate names suggests invalid Rust #45829

Closed
@Twey

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
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions