about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLoïc BRANSTETT <lolo.branstett@numericable.fr>2022-02-20 00:04:10 +0100
committerLoïc BRANSTETT <lolo.branstett@numericable.fr>2022-02-22 22:59:16 +0100
commitfbe1c153ecc88651a147517a6c1aea3da6aca8fc (patch)
tree87c5ce84dec99e316f584613e77ee6d4381d0e74
parentda896d35f471a27eb7b9385d6eadf50a5f761265 (diff)
downloadrust-fbe1c153ecc88651a147517a6c1aea3da6aca8fc.tar.gz
rust-fbe1c153ecc88651a147517a6c1aea3da6aca8fc.zip
Add test for well known names defined by rustc
-rw-r--r--src/test/ui/check-cfg/well-known-names.rs27
-rw-r--r--src/test/ui/check-cfg/well-known-names.stderr22
2 files changed, 49 insertions, 0 deletions
diff --git a/src/test/ui/check-cfg/well-known-names.rs b/src/test/ui/check-cfg/well-known-names.rs
new file mode 100644
index 00000000000..a66568a2ffd
--- /dev/null
+++ b/src/test/ui/check-cfg/well-known-names.rs
@@ -0,0 +1,27 @@
+// This test checks that we lint on non well known names and that we don't lint on well known names
+//
+// check-pass
+// compile-flags: --check-cfg=names() -Z unstable-options
+
+#[cfg(target_oz = "linux")]
+//~^ WARNING unexpected `cfg` condition name
+fn target_os_misspell() {}
+
+#[cfg(target_os = "linux")]
+fn target_os() {}
+
+#[cfg(features = "foo")]
+//~^ WARNING unexpected `cfg` condition name
+fn feature_misspell() {}
+
+#[cfg(feature = "foo")]
+fn feature() {}
+
+#[cfg(uniw)]
+//~^ WARNING unexpected `cfg` condition name
+fn unix_misspell() {}
+
+#[cfg(unix)]
+fn unix() {}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/well-known-names.stderr b/src/test/ui/check-cfg/well-known-names.stderr
new file mode 100644
index 00000000000..a6b9a77dc8d
--- /dev/null
+++ b/src/test/ui/check-cfg/well-known-names.stderr
@@ -0,0 +1,22 @@
+warning: unexpected `cfg` condition name
+  --> $DIR/well-known-names.rs:6:7
+   |
+LL | #[cfg(target_oz = "linux")]
+   |       ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: unexpected `cfg` condition name
+  --> $DIR/well-known-names.rs:13:7
+   |
+LL | #[cfg(features = "foo")]
+   |       ^^^^^^^^^^^^^^^^
+
+warning: unexpected `cfg` condition name
+  --> $DIR/well-known-names.rs:20:7
+   |
+LL | #[cfg(uniw)]
+   |       ^^^^
+
+warning: 3 warnings emitted
+