rust/tests/ui/useless_attribute.rs
Philipp Hansch 81f5969704
Partly fix incorrect useless_attribute suggestion
This fixes an incorrect suggestion from the `useless_attribute` lint
when using `cfg_attr`.

Additionally, it will not show a suggestion anymore, if the attribute
begins on a previous line, because it is much harder to construct the
span of multi-line `cfg_attr` attributes as they don't appear in the AST.

To fix it completely, one would have to parse upwards into the file,
and find the beginning of the `cfg_attr` attribute.
2018-02-06 22:35:11 +01:00

21 lines
502 B
Rust

#![warn(useless_attribute)]
#[allow(dead_code, unused_extern_crates)]
#[cfg_attr(feature = "cargo-clippy", allow(dead_code, unused_extern_crates))]
#[cfg_attr(feature = "cargo-clippy",
allow(dead_code, unused_extern_crates))]
extern crate clippy_lints;
// don't lint on unused_import for `use` items
#[allow(unused_imports)]
use std::collections;
// don't lint on deprecated for `use` items
mod foo { #[deprecated] pub struct Bar; }
#[allow(deprecated)]
pub use foo::Bar;
fn main() {}