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

Lint suggestion: warn on use statements already imported via the prelude #1124

Open
burtonageo opened this issue Jul 30, 2016 · 1 comment
Open
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-unnecessary Lint: Warn about unnecessary code

Comments

@burtonageo
Copy link

burtonageo commented Jul 30, 2016

A large number of traits, types and functions are imported into a rust crate implicitly through the standard prelude. However, when you explicitly bring one of these items in the prelude into scope using the use statement, the rust compiler doesn't warn that the use is unnecessary.

A clippy warning for this could help shave unnecessary lines. This should probably not run on crates with #![no_std]

@mcarton mcarton added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. A-lint Area: New lints L-unnecessary Lint: Warn about unnecessary code labels Jul 30, 2016
@yaahc
Copy link
Member

yaahc commented Apr 15, 2021

This came up in our libs team yesterday when discussing rust-lang/rust#82786. Josh summarized our conclusion but the gist is we want to rely on inherent traits but we expect that inherent traits to accomplish the PR's goal because it won't introduce a ton of new warnings the way the PR's implementation does, but this will have a similar issue to items in the prelude where it's possible to have unused imports that don't produce warnings.

Our suggestion was to add an allow by default lint to warn about these unnecessary imports, and to have it work for both prelude items and inherent traits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-unnecessary Lint: Warn about unnecessary code
Projects
None yet
Development

No branches or pull requests

3 participants