Closed
Description
The useless_attribute
lint is meant to warn about extern crate
and use
items with outer lint attributes (for example #[allow(dead_code)]
).
However, when this lint triggers on items that are preceded by other items, applying the suggestion will fail to compile.
Minimal example (Playground Link):
#![allow(unused_imports)]
fn main() {}
#[allow(dead_code)]
use aho_corasick;
Produces:
error: useless lint attribute
--> src/main.rs:6:1
|
6 | #[allow(dead_code)]
| ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]`
But applying the suggestion results in:
error: an inner attribute is not permitted in this context
--> src/main.rs:6:3
|
6 | #![allow(dead_code)]
| ^
To fix this, we could
a) Try to find a way to detect if the use
/extern crate
is preceded by any other items
b) Remove the suggestion completely if a) turns out impossible