about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2023-05-09 12:13:49 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2023-05-19 16:16:37 +0200
commitfcf19481aa17ea7bfaabc0bfae07aebc40248146 (patch)
tree92fb0540dc3ff568537d9d2fcc29aa4c5325e527
parentab66a86815a2bb562edef92ef8c308b6958ea734 (diff)
downloadrust-fcf19481aa17ea7bfaabc0bfae07aebc40248146.tar.gz
rust-fcf19481aa17ea7bfaabc0bfae07aebc40248146.zip
Add UI test for UNIQUE_CFG_CONDITION
-rw-r--r--tests/ui/non_minimal_cfg.fixed14
-rw-r--r--tests/ui/non_minimal_cfg.rs14
-rw-r--r--tests/ui/non_minimal_cfg.stderr28
3 files changed, 56 insertions, 0 deletions
diff --git a/tests/ui/non_minimal_cfg.fixed b/tests/ui/non_minimal_cfg.fixed
new file mode 100644
index 00000000000..ca9a48a3e37
--- /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 00000000000..bf322236fef
--- /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 00000000000..cdfd728aa61
--- /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
+