-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.
Description
I tried this code:
#[deprecated]
#[allow(unsafe_code)]
#[cfg(not(foo))]
use std::fs;
fn main() {}
I expected to see this happen: The suggestion should suggest removing use std::fs;
and its attributes.
Instead, this happened: The suggestion span does not encompass the attributes. This causes cargo fix
to remove the item, and leave the attributes applying to whatever happens to be next.
Meta
rustc 1.56.0-nightly (ccffcafd5 2021-08-11)
See also #56328 for a similar issue (although I think that one is subtly different).
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-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.