Skip to content

unused imports should not be fixed from use foo;\n to \n #66560

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

Open
samuela opened this issue Nov 18, 2019 · 1 comment
Open

unused imports should not be fixed from use foo;\n to \n #66560

samuela opened this issue Nov 18, 2019 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. E-help-wanted Call for participation: Help is requested to fix this issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@samuela
Copy link

samuela commented Nov 18, 2019

Right now rustfix fixes unused imports by removing but instead of replacing an unused import use foo;\n with ``, it inserts \n. This gets really annoying when you have a single block of imports and it ends up looking "hole punched":

use crate::archival::libarchive::bb_archive::file_header_t;
use crate::libbb::llist::llist_t;


use crate::librb::bb_uidgid_t;
use crate::librb::fd_pair;
use crate::librb::size_t;
use crate::librb::uoff_t;

use libc;
use libc::close;
use libc::fprintf;
use libc::free;

use libc::gid_t;
use libc::lstat;
use libc::mode_t;
use libc::off_t;
use libc::pid_t;

use libc::printf;
use libc::stat;

use libc::strcpy;
use libc::uid_t;
use libc::FILE;

On its own this wouldn't be that big of a deal but since these have now been split into separate import "blocks" rustfmt will no longer condense them.

@ehuss ehuss transferred this issue from rust-lang/rustfix Nov 19, 2019
@ehuss
Copy link
Contributor

ehuss commented Nov 19, 2019

Thanks for the report! I transferred this to rust-lang/rust, as that is where lints and suggestions are implemented.

This is very similar to #51176, and I suspect it will have the same concerns listed in that issue. There are also more details on how to approach that issue at rust-lang/rustfix#158 (comment).

@Alexendoo Alexendoo added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 20, 2019
@estebank estebank added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. labels Nov 20, 2019
@tmandry tmandry added the E-help-wanted Call for participation: Help is requested to fix this issue. label Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. E-help-wanted Call for participation: Help is requested to fix this issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants