Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing as other_ suggestion for duplicated import #52891

Closed
sinkuu opened this issue Jul 31, 2018 · 0 comments
Closed

Confusing as other_ suggestion for duplicated import #52891

sinkuu opened this issue Jul 31, 2018 · 0 comments
Assignees
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`

Comments

@sinkuu
Copy link
Contributor

sinkuu commented Jul 31, 2018

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;
  |     ^^^^^^^^^^^^^^^^^^^
@estebank estebank added the A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` label Jan 8, 2019
@davidtwco davidtwco self-assigned this Jan 29, 2019
bors added a commit that referenced this issue Feb 5, 2019
Add suggestion for duplicated import.

Fixes #52891.

This PR adds a suggestion when a import is duplicated (ie. the same name
is used twice trying to import the same thing) to remove the second
import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`
Projects
None yet
Development

No branches or pull requests

3 participants