diff --git a/tests/ui/cfg_attr_cargo_clippy.fixed b/tests/ui/cfg_attr_cargo_clippy.fixed new file mode 100644 index 00000000000..89815ffe9cb --- /dev/null +++ b/tests/ui/cfg_attr_cargo_clippy.fixed @@ -0,0 +1,13 @@ +#![warn(clippy::deprecated_clippy_cfg_attr)] +#![allow(clippy::non_minimal_cfg)] +#![cfg_attr(clippy, doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was + +#[cfg_attr(clippy, derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg_attr(not(clippy), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(clippy)] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(not(clippy))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(any(clippy))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(all(clippy))] //~ ERROR: `feature = "cargo-clippy"` was +pub struct Bar; + +fn main() {} diff --git a/tests/ui/cfg_attr_cargo_clippy.rs b/tests/ui/cfg_attr_cargo_clippy.rs new file mode 100644 index 00000000000..745f8957641 --- /dev/null +++ b/tests/ui/cfg_attr_cargo_clippy.rs @@ -0,0 +1,13 @@ +#![warn(clippy::deprecated_clippy_cfg_attr)] +#![allow(clippy::non_minimal_cfg)] +#![cfg_attr(feature = "cargo-clippy", doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was + +#[cfg_attr(feature = "cargo-clippy", derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(feature = "cargo-clippy")] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(not(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(any(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(all(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was +pub struct Bar; + +fn main() {} diff --git a/tests/ui/cfg_attr_cargo_clippy.stderr b/tests/ui/cfg_attr_cargo_clippy.stderr new file mode 100644 index 00000000000..0d67f8cd7bc --- /dev/null +++ b/tests/ui/cfg_attr_cargo_clippy.stderr @@ -0,0 +1,47 @@ +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:5:12 + | +LL | #[cfg_attr(feature = "cargo-clippy", derive(Debug))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + | + = note: `-D clippy::deprecated-clippy-cfg-attr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::deprecated_clippy_cfg_attr)]` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:6:16 + | +LL | #[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:7:7 + | +LL | #[cfg(feature = "cargo-clippy")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:8:11 + | +LL | #[cfg(not(feature = "cargo-clippy"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:9:11 + | +LL | #[cfg(any(feature = "cargo-clippy"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:10:11 + | +LL | #[cfg(all(feature = "cargo-clippy"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> $DIR/cfg_attr_cargo_clippy.rs:3:13 + | +LL | #![cfg_attr(feature = "cargo-clippy", doc = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: aborting due to 7 previous errors + diff --git a/tests/ui/useless_attribute.fixed b/tests/ui/useless_attribute.fixed index 98a2bed0e81..c7d611f36cf 100644 --- a/tests/ui/useless_attribute.fixed +++ b/tests/ui/useless_attribute.fixed @@ -6,7 +6,7 @@ #![feature(rustc_private)] #![allow(dead_code)] -#![cfg_attr(feature = "cargo-clippy", allow(dead_code))] +#![cfg_attr(clippy, allow(dead_code))] #[rustfmt::skip] #[allow(unused_imports)] #[allow(unused_extern_crates)] diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index c5e324717b1..00cfa8f5d54 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -6,7 +6,7 @@ #![feature(rustc_private)] #[allow(dead_code)] -#[cfg_attr(feature = "cargo-clippy", allow(dead_code))] +#[cfg_attr(clippy, allow(dead_code))] #[rustfmt::skip] #[allow(unused_imports)] #[allow(unused_extern_crates)] diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index e65c59abaf8..cfb429ce77f 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -10,8 +10,8 @@ LL | #[allow(dead_code)] error: useless lint attribute --> $DIR/useless_attribute.rs:9:1 | -LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` +LL | #[cfg_attr(clippy, allow(dead_code))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(clippy, allow(dead_code)` error: useless lint attribute --> $DIR/useless_attribute.rs:20:5