Skip to content

unused_imports suggestion does not remove attributes #87973

Closed

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-lintArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions