summaryrefslogtreecommitdiffstats
path: root/src/test/ui/check-cfg/mix.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/check-cfg/mix.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/check-cfg/mix.rs')
-rw-r--r--src/test/ui/check-cfg/mix.rs74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/test/ui/check-cfg/mix.rs b/src/test/ui/check-cfg/mix.rs
new file mode 100644
index 000000000..8e3d20d50
--- /dev/null
+++ b/src/test/ui/check-cfg/mix.rs
@@ -0,0 +1,74 @@
+// This test checks the combination of well known names, their activation via names(),
+// the usage of values(), and that no implicit is done with --cfg while also testing that
+// we correctly lint on the `cfg!` macro and `cfg_attr` attribute.
+//
+// check-pass
+// compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --cfg feature="bar" -Z unstable-options
+
+#[cfg(windows)]
+fn do_windows_stuff() {}
+
+#[cfg(widnows)]
+//~^ WARNING unexpected `cfg` condition name
+fn do_windows_stuff() {}
+
+#[cfg(feature = "foo")]
+fn use_foo() {}
+
+#[cfg(feature = "bar")]
+//~^ WARNING unexpected `cfg` condition value
+fn use_bar() {}
+
+#[cfg(feature = "zebra")]
+//~^ WARNING unexpected `cfg` condition value
+fn use_zebra() {}
+
+#[cfg_attr(uu, test)]
+//~^ WARNING unexpected `cfg` condition name
+fn do_test() {}
+
+#[cfg_attr(feature = "foo", no_mangle)]
+fn do_test_foo() {}
+
+fn test_cfg_macro() {
+ cfg!(windows);
+ cfg!(widnows);
+ //~^ WARNING unexpected `cfg` condition name
+ cfg!(feature = "foo");
+ cfg!(feature = "bar");
+ //~^ WARNING unexpected `cfg` condition value
+ cfg!(feature = "zebra");
+ //~^ WARNING unexpected `cfg` condition value
+ cfg!(xxx = "foo");
+ //~^ WARNING unexpected `cfg` condition name
+ cfg!(xxx);
+ //~^ WARNING unexpected `cfg` condition name
+ cfg!(any(xxx, windows));
+ //~^ WARNING unexpected `cfg` condition name
+ cfg!(any(feature = "bad", windows));
+ //~^ WARNING unexpected `cfg` condition value
+ cfg!(any(windows, xxx));
+ //~^ WARNING unexpected `cfg` condition name
+ cfg!(all(unix, xxx));
+ //~^ WARNING unexpected `cfg` condition name
+ cfg!(all(aa, bb));
+ //~^ WARNING unexpected `cfg` condition name
+ //~| WARNING unexpected `cfg` condition name
+ cfg!(any(aa, bb));
+ //~^ WARNING unexpected `cfg` condition name
+ //~| WARNING unexpected `cfg` condition name
+ cfg!(any(unix, feature = "zebra"));
+ //~^ WARNING unexpected `cfg` condition value
+ cfg!(any(xxx, feature = "zebra"));
+ //~^ WARNING unexpected `cfg` condition name
+ //~| WARNING unexpected `cfg` condition value
+ cfg!(any(xxx, unix, xxx));
+ //~^ WARNING unexpected `cfg` condition name
+ //~| WARNING unexpected `cfg` condition name
+ cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
+ //~^ WARNING unexpected `cfg` condition value
+ //~| WARNING unexpected `cfg` condition value
+ //~| WARNING unexpected `cfg` condition value
+}
+
+fn main() {}