Add ui tests for DEPRECATED_CLIPPY_CFG_ATTR

This commit is contained in:
Guillaume Gomez 2024-02-14 17:51:45 +01:00
parent e0f82af3dd
commit cd6f03a3e8
6 changed files with 77 additions and 4 deletions

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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

View File

@ -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)]

View File

@ -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)]

View File

@ -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