Closed as not planned
Closed as not planned
Description
Summary
cargo clippy --fix
can remove entire use
statements if all of the imported names are unused, but it leaves a blank line behind. With a large number of use
lines, this can result in imports being fragmented into multiple blocks that won't ever be joined back together. If clippy removes an entire use
statement, it should remove the trailing newline at the end, too.
Reproducer
I tried this code:
use std::any::Any;
use std::option::Option;
use std::result::Result;
use std::sync::Mutex;
pub fn use_some_imports() {
let _ = Mutex::new(());
let _ = Option::Some(32);
}
I expected to see this happen:
Running cargo clippy --fix
should have removed the use
lines for Any
and Result
and kept the block of imports together, like this:
use std::option::Option;
use std::sync::Mutex;
pub fn use_some_imports() {
let _ = Mutex::new(());
let _ = Option::Some(32);
}
Instead, this happened:
cargo clippy --fix
left blank lines, splitting the block of imports:
use std::option::Option;
use std::sync::Mutex;
pub fn use_some_imports() {
let _ = Mutex::new(());
let _ = Option::Some(32);
}
Version
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.75.0
LLVM version: 17.0.6
Additional Labels
No response