-
-
Notifications
You must be signed in to change notification settings - Fork 15k
cargo fix on unused use statements leaves empty lines behind. #120296
Copy link
Copy link
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Run
cargo fixon the following:Current output
cargo fix will remove the unused
usestatements but will leave an empty line behind for each one. In this case that is 3 empty lines:Desired output
No empty lines left behind:
Rationale and extra context
Leaving those empty lines around means they need to be manually cleaned up and I dont think there is ever a scenario where someone would want the empty line left behind.
I'm not sure if this is a cargo bug or a rustc bug.
I know rustc emits some kind of span to tell cargo what change needs to occur?
But maybe its cargo not interpreting the span correctly?
Other cases
No response
Rust Version
It has been this way for as long as I can remember but: 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.6Anything else?
No response