Skip to content

Confusing as other_ suggestion for duplicated import #52891

Closed
@sinkuu

Description

@sinkuu
use std::fs;
use std::fs;

This code generates a confusing suggestion. The compiler should instead suggest removing one of uses, or at least hide the help.

error[E0252]: the name `fs` is defined multiple times
 --> src/main.rs:2:5
  |
1 | use std::fs;
  |     ------- previous import of the module `fs` here
2 | use std::fs;
  |     ^^^^^^^ `fs` reimported here
  |
  = note: `fs` must be defined only once in the type namespace of this module
help: You can use `as` to change the binding name of the import
  |
2 | use std::fs as other_fs;
  |     ^^^^^^^^^^^^^^^^^^^

Metadata

Metadata

Assignees

Labels

A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions