From fcf19481aa17ea7bfaabc0bfae07aebc40248146 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 9 May 2023 12:13:49 +0200 Subject: [PATCH] Add UI test for UNIQUE_CFG_CONDITION --- tests/ui/non_minimal_cfg.fixed | 14 ++++++++++++++ tests/ui/non_minimal_cfg.rs | 14 ++++++++++++++ tests/ui/non_minimal_cfg.stderr | 28 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 tests/ui/non_minimal_cfg.fixed create mode 100644 tests/ui/non_minimal_cfg.rs create mode 100644 tests/ui/non_minimal_cfg.stderr diff --git a/tests/ui/non_minimal_cfg.fixed b/tests/ui/non_minimal_cfg.fixed new file mode 100644 index 000000000000..ca9a48a3e377 --- /dev/null +++ b/tests/ui/non_minimal_cfg.fixed @@ -0,0 +1,14 @@ +//@run-rustfix + +#![allow(unused)] + +#[cfg(windows)] +fn hermit() {} + +#[cfg(windows)] +fn wasi() {} + +#[cfg(all(unix, not(windows)))] +fn the_end() {} + +fn main() {} diff --git a/tests/ui/non_minimal_cfg.rs b/tests/ui/non_minimal_cfg.rs new file mode 100644 index 000000000000..bf322236fef7 --- /dev/null +++ b/tests/ui/non_minimal_cfg.rs @@ -0,0 +1,14 @@ +//@run-rustfix + +#![allow(unused)] + +#[cfg(all(windows))] +fn hermit() {} + +#[cfg(any(windows))] +fn wasi() {} + +#[cfg(all(any(unix), all(not(windows))))] +fn the_end() {} + +fn main() {} diff --git a/tests/ui/non_minimal_cfg.stderr b/tests/ui/non_minimal_cfg.stderr new file mode 100644 index 000000000000..cdfd728aa611 --- /dev/null +++ b/tests/ui/non_minimal_cfg.stderr @@ -0,0 +1,28 @@ +error: unneeded sub `cfg` when there is only one condition + --> $DIR/non_minimal_cfg.rs:5:7 + | +LL | #[cfg(all(windows))] + | ^^^^^^^^^^^^ help: try: `windows` + | + = note: `-D clippy::non-minimal-cfg` implied by `-D warnings` + +error: unneeded sub `cfg` when there is only one condition + --> $DIR/non_minimal_cfg.rs:8:7 + | +LL | #[cfg(any(windows))] + | ^^^^^^^^^^^^ help: try: `windows` + +error: unneeded sub `cfg` when there is only one condition + --> $DIR/non_minimal_cfg.rs:11:11 + | +LL | #[cfg(all(any(unix), all(not(windows))))] + | ^^^^^^^^^ help: try: `unix` + +error: unneeded sub `cfg` when there is only one condition + --> $DIR/non_minimal_cfg.rs:11:22 + | +LL | #[cfg(all(any(unix), all(not(windows))))] + | ^^^^^^^^^^^^^^^^^ help: try: `not(windows)` + +error: aborting due to 4 previous errors +