summaryrefslogtreecommitdiffstats
path: root/src/test/ui/check-cfg
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/check-cfg/allow-macro-cfg.rs14
-rw-r--r--src/test/ui/check-cfg/allow-same-level.rs11
-rw-r--r--src/test/ui/check-cfg/allow-same-level.stderr10
-rw-r--r--src/test/ui/check-cfg/allow-top-level.rs15
-rw-r--r--src/test/ui/check-cfg/allow-upper-level.rs12
-rw-r--r--src/test/ui/check-cfg/compact-names.rs15
-rw-r--r--src/test/ui/check-cfg/compact-names.stderr10
-rw-r--r--src/test/ui/check-cfg/compact-values.rs15
-rw-r--r--src/test/ui/check-cfg/compact-values.stderr11
-rw-r--r--src/test/ui/check-cfg/empty-names.rs10
-rw-r--r--src/test/ui/check-cfg/empty-names.stderr10
-rw-r--r--src/test/ui/check-cfg/empty-values.rs10
-rw-r--r--src/test/ui/check-cfg/empty-values.stderr13
-rw-r--r--src/test/ui/check-cfg/invalid-arguments.anything_else.stderr2
-rw-r--r--src/test/ui/check-cfg/invalid-arguments.names_simple_ident.stderr2
-rw-r--r--src/test/ui/check-cfg/invalid-arguments.rs10
-rw-r--r--src/test/ui/check-cfg/invalid-arguments.values_simple_ident.stderr2
-rw-r--r--src/test/ui/check-cfg/invalid-arguments.values_string_literals.stderr2
-rw-r--r--src/test/ui/check-cfg/invalid-cfg-name.rs14
-rw-r--r--src/test/ui/check-cfg/invalid-cfg-name.stderr10
-rw-r--r--src/test/ui/check-cfg/invalid-cfg-value.rs18
-rw-r--r--src/test/ui/check-cfg/invalid-cfg-value.stderr19
-rw-r--r--src/test/ui/check-cfg/mix.rs74
-rw-r--r--src/test/ui/check-cfg/mix.stderr174
-rw-r--r--src/test/ui/check-cfg/no-values.rs14
-rw-r--r--src/test/ui/check-cfg/no-values.stderr21
-rw-r--r--src/test/ui/check-cfg/stmt-no-ice.rs10
-rw-r--r--src/test/ui/check-cfg/stmt-no-ice.stderr10
-rw-r--r--src/test/ui/check-cfg/well-known-names.rs33
-rw-r--r--src/test/ui/check-cfg/well-known-names.stderr26
-rw-r--r--src/test/ui/check-cfg/well-known-values.rs42
-rw-r--r--src/test/ui/check-cfg/well-known-values.stderr53
32 files changed, 692 insertions, 0 deletions
diff --git a/src/test/ui/check-cfg/allow-macro-cfg.rs b/src/test/ui/check-cfg/allow-macro-cfg.rs
new file mode 100644
index 000000000..8016a4d19
--- /dev/null
+++ b/src/test/ui/check-cfg/allow-macro-cfg.rs
@@ -0,0 +1,14 @@
+// This test check that local #[allow(unexpected_cfgs)] works
+//
+// check-pass
+// compile-flags:--check-cfg=names() -Z unstable-options
+
+#[allow(unexpected_cfgs)]
+fn foo() {
+ if cfg!(FALSE) {}
+}
+
+fn main() {
+ #[allow(unexpected_cfgs)]
+ if cfg!(FALSE) {}
+}
diff --git a/src/test/ui/check-cfg/allow-same-level.rs b/src/test/ui/check-cfg/allow-same-level.rs
new file mode 100644
index 000000000..6c869dc42
--- /dev/null
+++ b/src/test/ui/check-cfg/allow-same-level.rs
@@ -0,0 +1,11 @@
+// This test check that #[allow(unexpected_cfgs)] doesn't work if put on the same level
+//
+// check-pass
+// compile-flags:--check-cfg=names() -Z unstable-options
+
+#[allow(unexpected_cfgs)]
+#[cfg(FALSE)]
+//~^ WARNING unexpected `cfg` condition name
+fn bar() {}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/allow-same-level.stderr b/src/test/ui/check-cfg/allow-same-level.stderr
new file mode 100644
index 000000000..7797de584
--- /dev/null
+++ b/src/test/ui/check-cfg/allow-same-level.stderr
@@ -0,0 +1,10 @@
+warning: unexpected `cfg` condition name
+ --> $DIR/allow-same-level.rs:7:7
+ |
+LL | #[cfg(FALSE)]
+ | ^^^^^
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/check-cfg/allow-top-level.rs b/src/test/ui/check-cfg/allow-top-level.rs
new file mode 100644
index 000000000..d14b0eae5
--- /dev/null
+++ b/src/test/ui/check-cfg/allow-top-level.rs
@@ -0,0 +1,15 @@
+// This test check that a top-level #![allow(unexpected_cfgs)] works
+//
+// check-pass
+// compile-flags:--check-cfg=names() -Z unstable-options
+
+#![allow(unexpected_cfgs)]
+
+#[cfg(FALSE)]
+fn bar() {}
+
+fn foo() {
+ if cfg!(FALSE) {}
+}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/allow-upper-level.rs b/src/test/ui/check-cfg/allow-upper-level.rs
new file mode 100644
index 000000000..04340694d
--- /dev/null
+++ b/src/test/ui/check-cfg/allow-upper-level.rs
@@ -0,0 +1,12 @@
+// This test check that #[allow(unexpected_cfgs)] work if put on an upper level
+//
+// check-pass
+// compile-flags:--check-cfg=names() -Z unstable-options
+
+#[allow(unexpected_cfgs)]
+mod aa {
+ #[cfg(FALSE)]
+ fn bar() {}
+}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/compact-names.rs b/src/test/ui/check-cfg/compact-names.rs
new file mode 100644
index 000000000..bff807400
--- /dev/null
+++ b/src/test/ui/check-cfg/compact-names.rs
@@ -0,0 +1,15 @@
+// This test check that we correctly emit an warning for compact cfg
+//
+// check-pass
+// compile-flags:--check-cfg=names() -Z unstable-options
+
+#![feature(cfg_target_compact)]
+
+#[cfg(target(os = "linux", arch = "arm"))]
+pub fn expected() {}
+
+#[cfg(target(os = "linux", architecture = "arm"))]
+//~^ WARNING unexpected `cfg` condition name
+pub fn unexpected() {}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/compact-names.stderr b/src/test/ui/check-cfg/compact-names.stderr
new file mode 100644
index 000000000..f1fc4285a
--- /dev/null
+++ b/src/test/ui/check-cfg/compact-names.stderr
@@ -0,0 +1,10 @@
+warning: unexpected `cfg` condition name
+ --> $DIR/compact-names.rs:11:28
+ |
+LL | #[cfg(target(os = "linux", architecture = "arm"))]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/check-cfg/compact-values.rs b/src/test/ui/check-cfg/compact-values.rs
new file mode 100644
index 000000000..1f1705784
--- /dev/null
+++ b/src/test/ui/check-cfg/compact-values.rs
@@ -0,0 +1,15 @@
+// This test check that we correctly emit an warning for compact cfg
+//
+// check-pass
+// compile-flags:--check-cfg=values() -Z unstable-options
+
+#![feature(cfg_target_compact)]
+
+#[cfg(target(os = "linux", arch = "arm"))]
+pub fn expected() {}
+
+#[cfg(target(os = "linux", arch = "X"))]
+//~^ WARNING unexpected `cfg` condition value
+pub fn unexpected() {}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/compact-values.stderr b/src/test/ui/check-cfg/compact-values.stderr
new file mode 100644
index 000000000..a196e1537
--- /dev/null
+++ b/src/test/ui/check-cfg/compact-values.stderr
@@ -0,0 +1,11 @@
+warning: unexpected `cfg` condition value
+ --> $DIR/compact-values.rs:11:28
+ |
+LL | #[cfg(target(os = "linux", arch = "X"))]
+ | ^^^^^^^^^^
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+ = note: expected values for `target_arch` are: aarch64, arm, avr, bpf, hexagon, m68k, mips, mips64, msp430, nvptx64, powerpc, powerpc64, riscv32, riscv64, s390x, sparc, sparc64, wasm32, wasm64, x86, x86_64
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/check-cfg/empty-names.rs b/src/test/ui/check-cfg/empty-names.rs
new file mode 100644
index 000000000..046ff0364
--- /dev/null
+++ b/src/test/ui/check-cfg/empty-names.rs
@@ -0,0 +1,10 @@
+// Check warning for unexpected cfg
+//
+// check-pass
+// compile-flags: --check-cfg=names() -Z unstable-options
+
+#[cfg(unknown_key = "value")]
+//~^ WARNING unexpected `cfg` condition name
+pub fn f() {}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/empty-names.stderr b/src/test/ui/check-cfg/empty-names.stderr
new file mode 100644
index 000000000..f926d1133
--- /dev/null
+++ b/src/test/ui/check-cfg/empty-names.stderr
@@ -0,0 +1,10 @@
+warning: unexpected `cfg` condition name
+ --> $DIR/empty-names.rs:6:7
+ |
+LL | #[cfg(unknown_key = "value")]
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/check-cfg/empty-values.rs b/src/test/ui/check-cfg/empty-values.rs
new file mode 100644
index 000000000..9bda42e5d
--- /dev/null
+++ b/src/test/ui/check-cfg/empty-values.rs
@@ -0,0 +1,10 @@
+// Check warning for unexpected cfg value
+//
+// check-pass
+// compile-flags: --check-cfg=values() -Z unstable-options
+
+#[cfg(test = "value")]
+//~^ WARNING unexpected `cfg` condition value
+pub fn f() {}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/empty-values.stderr b/src/test/ui/check-cfg/empty-values.stderr
new file mode 100644
index 000000000..10dab5034
--- /dev/null
+++ b/src/test/ui/check-cfg/empty-values.stderr
@@ -0,0 +1,13 @@
+warning: unexpected `cfg` condition value
+ --> $DIR/empty-values.rs:6:7
+ |
+LL | #[cfg(test = "value")]
+ | ^^^^----------
+ | |
+ | help: remove the value
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+ = note: no expected value for `test`
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/check-cfg/invalid-arguments.anything_else.stderr b/src/test/ui/check-cfg/invalid-arguments.anything_else.stderr
new file mode 100644
index 000000000..850924d99
--- /dev/null
+++ b/src/test/ui/check-cfg/invalid-arguments.anything_else.stderr
@@ -0,0 +1,2 @@
+error: invalid `--check-cfg` argument: `anything_else(...)` (expected `names(name1, name2, ... nameN)` or `values(name, "value1", "value2", ... "valueN")`)
+
diff --git a/src/test/ui/check-cfg/invalid-arguments.names_simple_ident.stderr b/src/test/ui/check-cfg/invalid-arguments.names_simple_ident.stderr
new file mode 100644
index 000000000..bdfbc3d54
--- /dev/null
+++ b/src/test/ui/check-cfg/invalid-arguments.names_simple_ident.stderr
@@ -0,0 +1,2 @@
+error: invalid `--check-cfg` argument: `names("NOT_IDENT")` (`names()` arguments must be simple identifers)
+
diff --git a/src/test/ui/check-cfg/invalid-arguments.rs b/src/test/ui/check-cfg/invalid-arguments.rs
new file mode 100644
index 000000000..5090ce3e8
--- /dev/null
+++ b/src/test/ui/check-cfg/invalid-arguments.rs
@@ -0,0 +1,10 @@
+// Check that invalid --check-cfg are rejected
+//
+// check-fail
+// revisions: anything_else names_simple_ident values_simple_ident values_string_literals
+// [anything_else]compile-flags: -Z unstable-options --check-cfg=anything_else(...)
+// [names_simple_ident]compile-flags: -Z unstable-options --check-cfg=names("NOT_IDENT")
+// [values_simple_ident]compile-flags: -Z unstable-options --check-cfg=values("NOT_IDENT")
+// [values_string_literals]compile-flags: -Z unstable-options --check-cfg=values(test,12)
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/invalid-arguments.values_simple_ident.stderr b/src/test/ui/check-cfg/invalid-arguments.values_simple_ident.stderr
new file mode 100644
index 000000000..b25882baa
--- /dev/null
+++ b/src/test/ui/check-cfg/invalid-arguments.values_simple_ident.stderr
@@ -0,0 +1,2 @@
+error: invalid `--check-cfg` argument: `values("NOT_IDENT")` (`values()` first argument must be a simple identifer)
+
diff --git a/src/test/ui/check-cfg/invalid-arguments.values_string_literals.stderr b/src/test/ui/check-cfg/invalid-arguments.values_string_literals.stderr
new file mode 100644
index 000000000..5853b4741
--- /dev/null
+++ b/src/test/ui/check-cfg/invalid-arguments.values_string_literals.stderr
@@ -0,0 +1,2 @@
+error: invalid `--check-cfg` argument: `values(test,12)` (`values()` arguments must be string literals)
+
diff --git a/src/test/ui/check-cfg/invalid-cfg-name.rs b/src/test/ui/check-cfg/invalid-cfg-name.rs
new file mode 100644
index 000000000..8499d3d44
--- /dev/null
+++ b/src/test/ui/check-cfg/invalid-cfg-name.rs
@@ -0,0 +1,14 @@
+// Check warning for invalid configuration name
+//
+// edition:2018
+// check-pass
+// compile-flags: --check-cfg=names() -Z unstable-options
+
+#[cfg(widnows)]
+//~^ WARNING unexpected `cfg` condition name
+pub fn f() {}
+
+#[cfg(windows)]
+pub fn g() {}
+
+pub fn main() {}
diff --git a/src/test/ui/check-cfg/invalid-cfg-name.stderr b/src/test/ui/check-cfg/invalid-cfg-name.stderr
new file mode 100644
index 000000000..2bd1821c9
--- /dev/null
+++ b/src/test/ui/check-cfg/invalid-cfg-name.stderr
@@ -0,0 +1,10 @@
+warning: unexpected `cfg` condition name
+ --> $DIR/invalid-cfg-name.rs:7:7
+ |
+LL | #[cfg(widnows)]
+ | ^^^^^^^ help: did you mean: `windows`
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/check-cfg/invalid-cfg-value.rs b/src/test/ui/check-cfg/invalid-cfg-value.rs
new file mode 100644
index 000000000..9e428d367
--- /dev/null
+++ b/src/test/ui/check-cfg/invalid-cfg-value.rs
@@ -0,0 +1,18 @@
+// Check warning for invalid configuration value
+//
+// edition:2018
+// check-pass
+// compile-flags: --check-cfg=values(feature,"serde","full") --cfg=feature="rand" -Z unstable-options
+
+#[cfg(feature = "sedre")]
+//~^ WARNING unexpected `cfg` condition value
+pub fn f() {}
+
+#[cfg(feature = "serde")]
+pub fn g() {}
+
+#[cfg(feature = "rand")]
+//~^ WARNING unexpected `cfg` condition value
+pub fn h() {}
+
+pub fn main() {}
diff --git a/src/test/ui/check-cfg/invalid-cfg-value.stderr b/src/test/ui/check-cfg/invalid-cfg-value.stderr
new file mode 100644
index 000000000..6cce31d33
--- /dev/null
+++ b/src/test/ui/check-cfg/invalid-cfg-value.stderr
@@ -0,0 +1,19 @@
+warning: unexpected `cfg` condition value
+ --> $DIR/invalid-cfg-value.rs:7:7
+ |
+LL | #[cfg(feature = "sedre")]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+ = note: expected values for `feature` are: full, serde
+
+warning: unexpected `cfg` condition value
+ --> $DIR/invalid-cfg-value.rs:14:7
+ |
+LL | #[cfg(feature = "rand")]
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: full, serde
+
+warning: 2 warnings emitted
+
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() {}
diff --git a/src/test/ui/check-cfg/mix.stderr b/src/test/ui/check-cfg/mix.stderr
new file mode 100644
index 000000000..e51b75b3d
--- /dev/null
+++ b/src/test/ui/check-cfg/mix.stderr
@@ -0,0 +1,174 @@
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:11:7
+ |
+LL | #[cfg(widnows)]
+ | ^^^^^^^ help: did you mean: `windows`
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:18:7
+ |
+LL | #[cfg(feature = "bar")]
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:22:7
+ |
+LL | #[cfg(feature = "zebra")]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:26:12
+ |
+LL | #[cfg_attr(uu, test)]
+ | ^^
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:35:10
+ |
+LL | cfg!(widnows);
+ | ^^^^^^^ help: did you mean: `windows`
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:38:10
+ |
+LL | cfg!(feature = "bar");
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:40:10
+ |
+LL | cfg!(feature = "zebra");
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:42:10
+ |
+LL | cfg!(xxx = "foo");
+ | ^^^^^^^^^^^
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:44:10
+ |
+LL | cfg!(xxx);
+ | ^^^
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:46:14
+ |
+LL | cfg!(any(xxx, windows));
+ | ^^^
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:48:14
+ |
+LL | cfg!(any(feature = "bad", windows));
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:50:23
+ |
+LL | cfg!(any(windows, xxx));
+ | ^^^
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:52:20
+ |
+LL | cfg!(all(unix, xxx));
+ | ^^^
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:54:14
+ |
+LL | cfg!(all(aa, bb));
+ | ^^
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:54:18
+ |
+LL | cfg!(all(aa, bb));
+ | ^^
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:57:14
+ |
+LL | cfg!(any(aa, bb));
+ | ^^
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:57:18
+ |
+LL | cfg!(any(aa, bb));
+ | ^^
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:60:20
+ |
+LL | cfg!(any(unix, feature = "zebra"));
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:62:14
+ |
+LL | cfg!(any(xxx, feature = "zebra"));
+ | ^^^
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:62:19
+ |
+LL | cfg!(any(xxx, feature = "zebra"));
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:65:14
+ |
+LL | cfg!(any(xxx, unix, xxx));
+ | ^^^
+
+warning: unexpected `cfg` condition name
+ --> $DIR/mix.rs:65:25
+ |
+LL | cfg!(any(xxx, unix, xxx));
+ | ^^^
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:68:14
+ |
+LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:68:33
+ |
+LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: unexpected `cfg` condition value
+ --> $DIR/mix.rs:68:52
+ |
+LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: expected values for `feature` are: foo
+
+warning: 25 warnings emitted
+
diff --git a/src/test/ui/check-cfg/no-values.rs b/src/test/ui/check-cfg/no-values.rs
new file mode 100644
index 000000000..8c80f56cb
--- /dev/null
+++ b/src/test/ui/check-cfg/no-values.rs
@@ -0,0 +1,14 @@
+// Check that we detect unexpected value when none are allowed
+//
+// check-pass
+// compile-flags: --check-cfg=values(test) --check-cfg=values(feature) -Z unstable-options
+
+#[cfg(feature = "foo")]
+//~^ WARNING unexpected `cfg` condition value
+fn do_foo() {}
+
+#[cfg(test = "foo")]
+//~^ WARNING unexpected `cfg` condition value
+fn do_foo() {}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/no-values.stderr b/src/test/ui/check-cfg/no-values.stderr
new file mode 100644
index 000000000..7025b4cd7
--- /dev/null
+++ b/src/test/ui/check-cfg/no-values.stderr
@@ -0,0 +1,21 @@
+warning: unexpected `cfg` condition value
+ --> $DIR/no-values.rs:6:7
+ |
+LL | #[cfg(feature = "foo")]
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+ = note: no expected value for `feature`
+
+warning: unexpected `cfg` condition value
+ --> $DIR/no-values.rs:10:7
+ |
+LL | #[cfg(test = "foo")]
+ | ^^^^--------
+ | |
+ | help: remove the value
+ |
+ = note: no expected value for `test`
+
+warning: 2 warnings emitted
+
diff --git a/src/test/ui/check-cfg/stmt-no-ice.rs b/src/test/ui/check-cfg/stmt-no-ice.rs
new file mode 100644
index 000000000..cf76487ed
--- /dev/null
+++ b/src/test/ui/check-cfg/stmt-no-ice.rs
@@ -0,0 +1,10 @@
+// This test checks that there is no ICE with this code
+//
+// check-pass
+// compile-flags:--check-cfg=names() -Z unstable-options
+
+fn main() {
+ #[cfg(crossbeam_loom)]
+ //~^ WARNING unexpected `cfg` condition name
+ {}
+}
diff --git a/src/test/ui/check-cfg/stmt-no-ice.stderr b/src/test/ui/check-cfg/stmt-no-ice.stderr
new file mode 100644
index 000000000..da65b5969
--- /dev/null
+++ b/src/test/ui/check-cfg/stmt-no-ice.stderr
@@ -0,0 +1,10 @@
+warning: unexpected `cfg` condition name
+ --> $DIR/stmt-no-ice.rs:7:11
+ |
+LL | #[cfg(crossbeam_loom)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: 1 warning emitted
+
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 000000000..e57fb69a1
--- /dev/null
+++ b/src/test/ui/check-cfg/well-known-names.rs
@@ -0,0 +1,33 @@
+// 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() {}
+
+#[cfg(miri)]
+fn miri() {}
+
+#[cfg(doc)]
+fn doc() {}
+
+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 000000000..bdbe4d29d
--- /dev/null
+++ b/src/test/ui/check-cfg/well-known-names.stderr
@@ -0,0 +1,26 @@
+warning: unexpected `cfg` condition name
+ --> $DIR/well-known-names.rs:6:7
+ |
+LL | #[cfg(target_oz = "linux")]
+ | ---------^^^^^^^^^^
+ | |
+ | help: did you mean: `target_os`
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: unexpected `cfg` condition name
+ --> $DIR/well-known-names.rs:13:7
+ |
+LL | #[cfg(features = "foo")]
+ | --------^^^^^^^^
+ | |
+ | help: did you mean: `feature`
+
+warning: unexpected `cfg` condition name
+ --> $DIR/well-known-names.rs:20:7
+ |
+LL | #[cfg(uniw)]
+ | ^^^^ help: did you mean: `unix`
+
+warning: 3 warnings emitted
+
diff --git a/src/test/ui/check-cfg/well-known-values.rs b/src/test/ui/check-cfg/well-known-values.rs
new file mode 100644
index 000000000..96375dc8d
--- /dev/null
+++ b/src/test/ui/check-cfg/well-known-values.rs
@@ -0,0 +1,42 @@
+// This test check that we lint on non well known values and that we don't lint on well known
+// values
+//
+// check-pass
+// compile-flags: --check-cfg=values() -Z unstable-options
+
+#[cfg(target_os = "linuz")]
+//~^ WARNING unexpected `cfg` condition value
+fn target_os_linux_misspell() {}
+
+#[cfg(target_os = "linux")]
+fn target_os_linux() {}
+
+#[cfg(target_has_atomic = "0")]
+//~^ WARNING unexpected `cfg` condition value
+fn target_has_atomic_invalid() {}
+
+#[cfg(target_has_atomic = "8")]
+fn target_has_atomic() {}
+
+#[cfg(unix = "aa")]
+//~^ WARNING unexpected `cfg` condition value
+fn unix_with_value() {}
+
+#[cfg(unix)]
+fn unix() {}
+
+#[cfg(miri = "miri")]
+//~^ WARNING unexpected `cfg` condition value
+fn miri_with_value() {}
+
+#[cfg(miri)]
+fn miri() {}
+
+#[cfg(doc = "linux")]
+//~^ WARNING unexpected `cfg` condition value
+fn doc_with_value() {}
+
+#[cfg(doc)]
+fn doc() {}
+
+fn main() {}
diff --git a/src/test/ui/check-cfg/well-known-values.stderr b/src/test/ui/check-cfg/well-known-values.stderr
new file mode 100644
index 000000000..24ce2280c
--- /dev/null
+++ b/src/test/ui/check-cfg/well-known-values.stderr
@@ -0,0 +1,53 @@
+warning: unexpected `cfg` condition value
+ --> $DIR/well-known-values.rs:7:7
+ |
+LL | #[cfg(target_os = "linuz")]
+ | ^^^^^^^^^^^^-------
+ | |
+ | help: did you mean: `"linux"`
+ |
+ = note: `#[warn(unexpected_cfgs)]` on by default
+ = note: expected values for `target_os` are: android, cuda, dragonfly, emscripten, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vxworks, wasi, watchos, windows, xous
+
+warning: unexpected `cfg` condition value
+ --> $DIR/well-known-values.rs:14:7
+ |
+LL | #[cfg(target_has_atomic = "0")]
+ | ^^^^^^^^^^^^^^^^^^^^---
+ | |
+ | help: did you mean: `"8"`
+ |
+ = note: expected values for `target_has_atomic` are: 128, 16, 32, 64, 8, ptr
+
+warning: unexpected `cfg` condition value
+ --> $DIR/well-known-values.rs:21:7
+ |
+LL | #[cfg(unix = "aa")]
+ | ^^^^-------
+ | |
+ | help: remove the value
+ |
+ = note: no expected value for `unix`
+
+warning: unexpected `cfg` condition value
+ --> $DIR/well-known-values.rs:28:7
+ |
+LL | #[cfg(miri = "miri")]
+ | ^^^^---------
+ | |
+ | help: remove the value
+ |
+ = note: no expected value for `miri`
+
+warning: unexpected `cfg` condition value
+ --> $DIR/well-known-values.rs:35:7
+ |
+LL | #[cfg(doc = "linux")]
+ | ^^^----------
+ | |
+ | help: remove the value
+ |
+ = note: no expected value for `doc`
+
+warning: 5 warnings emitted
+