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

Make cargo fix remove unused imports #6278

Closed
hirschenberger opened this issue Nov 7, 2018 · 4 comments
Closed

Make cargo fix remove unused imports #6278

hirschenberger opened this issue Nov 7, 2018 · 4 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-fix

Comments

@hirschenberger
Copy link

Describe the problem you are trying to solve

It would be great, if cargo fix could remove unused imports. Import handling is already tedious when using many dependencies without preludes and so it would be great it cargo could automatically remove the superfluous imports.

Describe the solution you'd like

cargo fix and all warning: unused import:... messages are gone.

Notes

Unfortunately rustc does not give a hint, how to get rid of the warning. So one could either handle the fix in cargo itself or extend rustc's warning message.

@alexcrichton
Copy link
Member

Thanks for the report! This is covered by rust-lang/rust#50723 in upstream rust-lang/rust as it'll need support from rustc to emit the right fix annotations.

@alexcrichton alexcrichton added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-fix labels Nov 8, 2018
@dwijnand
Copy link
Member

Duplicate of #5846

@dwijnand dwijnand marked this as a duplicate of #5846 Dec 12, 2018
@cjhopman
Copy link

@alexcrichton The upstream issue is now closed, but afaict cargo fix still doesn't remove unused imports. Am I missing something?

@cjhopman
Copy link

Maybe rust-lang/rust#47888 or rust-lang/rust#53934 cover what remains to support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-fix
Projects
None yet
Development

No branches or pull requests

4 participants