Skip to content

Commit a341893

Browse files
committed
Add run-rustfix for useless_attribute test
1 parent b6e87c6 commit a341893

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

tests/ui/useless_attribute.fixed

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// run-rustfix
2+
// aux-build:proc_macro_derive.rs
3+
4+
#![warn(clippy::useless_attribute)]
5+
#![warn(unreachable_pub)]
6+
7+
#![allow(dead_code)]
8+
#![cfg_attr(feature = "cargo-clippy", allow(dead_code))]
9+
#[rustfmt::skip]
10+
#[cfg_attr(feature = "cargo-clippy",
11+
allow(dead_code))]
12+
#[allow(unused_imports)]
13+
#[allow(unused_extern_crates)]
14+
#[macro_use]
15+
extern crate clippy_lints;
16+
17+
#[macro_use]
18+
extern crate proc_macro_derive;
19+
20+
// don't lint on unused_import for `use` items
21+
#[allow(unused_imports)]
22+
use std::collections;
23+
24+
// don't lint on deprecated for `use` items
25+
mod foo {
26+
#[deprecated]
27+
pub struct Bar;
28+
}
29+
#[allow(deprecated)]
30+
pub use foo::Bar;
31+
32+
// This should not trigger the lint. There's lint level definitions inside the external derive
33+
// that would trigger the useless_attribute lint.
34+
#[derive(DeriveSomething)]
35+
struct Baz;
36+
37+
// don't lint on unreachable_pub for `use` items
38+
mod a {
39+
mod b {
40+
#[allow(dead_code)]
41+
#[allow(unreachable_pub)]
42+
pub struct C {}
43+
}
44+
45+
#[allow(unreachable_pub)]
46+
pub use self::b::C;
47+
}
48+
49+
fn main() {}

tests/ui/useless_attribute.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// run-rustfix
12
// aux-build:proc_macro_derive.rs
23

34
#![warn(clippy::useless_attribute)]

tests/ui/useless_attribute.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: useless lint attribute
2-
--> $DIR/useless_attribute.rs:6:1
2+
--> $DIR/useless_attribute.rs:7:1
33
|
44
LL | #[allow(dead_code)]
55
| ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]`
66
|
77
= note: `-D clippy::useless-attribute` implied by `-D warnings`
88

99
error: useless lint attribute
10-
--> $DIR/useless_attribute.rs:7:1
10+
--> $DIR/useless_attribute.rs:8:1
1111
|
1212
LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)`

0 commit comments

Comments
 (0)