Skip to content

Commit cd6f03a

Browse files
Add ui tests for DEPRECATED_CLIPPY_CFG_ATTR
1 parent e0f82af commit cd6f03a

6 files changed

+77
-4
lines changed

tests/ui/cfg_attr_cargo_clippy.fixed

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![warn(clippy::deprecated_clippy_cfg_attr)]
2+
#![allow(clippy::non_minimal_cfg)]
3+
#![cfg_attr(clippy, doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was
4+
5+
#[cfg_attr(clippy, derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was
6+
#[cfg_attr(not(clippy), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was
7+
#[cfg(clippy)] //~ ERROR: `feature = "cargo-clippy"` was
8+
#[cfg(not(clippy))] //~ ERROR: `feature = "cargo-clippy"` was
9+
#[cfg(any(clippy))] //~ ERROR: `feature = "cargo-clippy"` was
10+
#[cfg(all(clippy))] //~ ERROR: `feature = "cargo-clippy"` was
11+
pub struct Bar;
12+
13+
fn main() {}

tests/ui/cfg_attr_cargo_clippy.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![warn(clippy::deprecated_clippy_cfg_attr)]
2+
#![allow(clippy::non_minimal_cfg)]
3+
#![cfg_attr(feature = "cargo-clippy", doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was
4+
5+
#[cfg_attr(feature = "cargo-clippy", derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was
6+
#[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was
7+
#[cfg(feature = "cargo-clippy")] //~ ERROR: `feature = "cargo-clippy"` was
8+
#[cfg(not(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was
9+
#[cfg(any(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was
10+
#[cfg(all(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was
11+
pub struct Bar;
12+
13+
fn main() {}

tests/ui/cfg_attr_cargo_clippy.stderr

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
error: `feature = "cargo-clippy"` was replaced by `clippy`
2+
--> $DIR/cfg_attr_cargo_clippy.rs:5:12
3+
|
4+
LL | #[cfg_attr(feature = "cargo-clippy", derive(Debug))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy`
6+
|
7+
= note: `-D clippy::deprecated-clippy-cfg-attr` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::deprecated_clippy_cfg_attr)]`
9+
10+
error: `feature = "cargo-clippy"` was replaced by `clippy`
11+
--> $DIR/cfg_attr_cargo_clippy.rs:6:16
12+
|
13+
LL | #[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy`
15+
16+
error: `feature = "cargo-clippy"` was replaced by `clippy`
17+
--> $DIR/cfg_attr_cargo_clippy.rs:7:7
18+
|
19+
LL | #[cfg(feature = "cargo-clippy")]
20+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy`
21+
22+
error: `feature = "cargo-clippy"` was replaced by `clippy`
23+
--> $DIR/cfg_attr_cargo_clippy.rs:8:11
24+
|
25+
LL | #[cfg(not(feature = "cargo-clippy"))]
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy`
27+
28+
error: `feature = "cargo-clippy"` was replaced by `clippy`
29+
--> $DIR/cfg_attr_cargo_clippy.rs:9:11
30+
|
31+
LL | #[cfg(any(feature = "cargo-clippy"))]
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy`
33+
34+
error: `feature = "cargo-clippy"` was replaced by `clippy`
35+
--> $DIR/cfg_attr_cargo_clippy.rs:10:11
36+
|
37+
LL | #[cfg(all(feature = "cargo-clippy"))]
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy`
39+
40+
error: `feature = "cargo-clippy"` was replaced by `clippy`
41+
--> $DIR/cfg_attr_cargo_clippy.rs:3:13
42+
|
43+
LL | #![cfg_attr(feature = "cargo-clippy", doc = "a")]
44+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy`
45+
46+
error: aborting due to 7 previous errors
47+

tests/ui/useless_attribute.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![feature(rustc_private)]
77

88
#![allow(dead_code)]
9-
#![cfg_attr(feature = "cargo-clippy", allow(dead_code))]
9+
#![cfg_attr(clippy, allow(dead_code))]
1010
#[rustfmt::skip]
1111
#[allow(unused_imports)]
1212
#[allow(unused_extern_crates)]

tests/ui/useless_attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![feature(rustc_private)]
77

88
#[allow(dead_code)]
9-
#[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
9+
#[cfg_attr(clippy, allow(dead_code))]
1010
#[rustfmt::skip]
1111
#[allow(unused_imports)]
1212
#[allow(unused_extern_crates)]

tests/ui/useless_attribute.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ LL | #[allow(dead_code)]
1010
error: useless lint attribute
1111
--> $DIR/useless_attribute.rs:9:1
1212
|
13-
LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)`
13+
LL | #[cfg_attr(clippy, allow(dead_code))]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(clippy, allow(dead_code)`
1515

1616
error: useless lint attribute
1717
--> $DIR/useless_attribute.rs:20:5

0 commit comments

Comments
 (0)