Skip to content

Suggest renaming a trait import if the names clash #32354

Closed
@bluss

Description

@bluss

You can bring in multiple traits of the same name if you rename them.

Example use case (playground code)

use extension1::ConstructorExtension;
use extension2::ConstructorExtension;

current error:

<anon>:49:5: 49:37 error: a trait named `ConstructorExtension` has already been imported in this module [E0252]
<anon>:49 use extension2::ConstructorExtension;
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:49:5: 49:37 help: see the detailed explanation for E0252
<anon>:48:5: 48:37 note: previous import of `ConstructorExtension` here
<anon>:48 use extension1::ConstructorExtension;
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Suggested note: "You can rename an imported name with as".

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions