about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-07-31 23:39:38 +0200
committerGitHub <noreply@github.com>2022-07-31 23:39:38 +0200
commite820ecdba115e56d3d1cb0df169463a23a28fabd (patch)
tree37b65f75c372f11543405fc80fe66fcc2a02bfc3 /src/test
parent3405e402faf413ef4633142225228c260a91dd9d (diff)
parentebf4cc361e0d0f11a25b42372bd629953365d17e (diff)
Rollup merge of #99519 - Urgau:check-cfg-implicit, r=petrochenkov
Remove implicit names and values from `--cfg` in `--check-cfg`

This PR remove the implicit names and values from `--cfg` in `--check-cfg` because the behavior is quite surprising but also because it's really easy to inadvertently really on the implicitness and when the `--cfg` is not set anymore to have an unexpected warning from an unexpected condition that pass with the implicitness.

This change in behavior will also enable us to warn when an unexpected `--cfg` is passed, ex: the user wrote `--cfg=unstabl` instead of `--cfg=unstable`. The implementation of the warning will be done in a follow-up PR.

cc `@petrochenkov`
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/check-cfg/invalid-cfg-value.rs1
-rw-r--r--src/test/ui/check-cfg/invalid-cfg-value.stderr12
-rw-r--r--src/test/ui/check-cfg/mix.rs8
-rw-r--r--src/test/ui/check-cfg/mix.stderr80
4 files changed, 63 insertions, 38 deletions
diff --git a/src/test/ui/check-cfg/invalid-cfg-value.rs b/src/test/ui/check-cfg/invalid-cfg-value.rs
index a60095a5aae..9e428d367fd 100644
--- a/src/test/ui/check-cfg/invalid-cfg-value.rs
+++ b/src/test/ui/check-cfg/invalid-cfg-value.rs
@@ -12,6 +12,7 @@ pub fn f() {}
 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
index bc2c053fed6..6cce31d3392 100644
--- a/src/test/ui/check-cfg/invalid-cfg-value.stderr
+++ b/src/test/ui/check-cfg/invalid-cfg-value.stderr
@@ -5,7 +5,15 @@ LL | #[cfg(feature = "sedre")]
    |       ^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(unexpected_cfgs)]` on by default
-   = note: expected values for `feature` are: full, rand, serde
+   = note: expected values for `feature` are: full, serde
 
-warning: 1 warning emitted
+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
index b51d356f61f..8e3d20d5045 100644
--- a/src/test/ui/check-cfg/mix.rs
+++ b/src/test/ui/check-cfg/mix.rs
@@ -1,6 +1,6 @@
-// This test checks the combination of well known names, their activation via names(), the usage of
-// partial values() with a --cfg and test that we also correctly lint on the `cfg!` macro and
-// `cfg_attr` attribute.
+// 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
@@ -16,6 +16,7 @@ fn do_windows_stuff() {}
 fn use_foo() {}
 
 #[cfg(feature = "bar")]
+//~^ WARNING unexpected `cfg` condition value
 fn use_bar() {}
 
 #[cfg(feature = "zebra")]
@@ -35,6 +36,7 @@ fn test_cfg_macro() {
     //~^ 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");
diff --git a/src/test/ui/check-cfg/mix.stderr b/src/test/ui/check-cfg/mix.stderr
index 08a338da104..e51b75b3d43 100644
--- a/src/test/ui/check-cfg/mix.stderr
+++ b/src/test/ui/check-cfg/mix.stderr
@@ -7,21 +7,29 @@ LL | #[cfg(widnows)]
    = note: `#[warn(unexpected_cfgs)]` on by default
 
 warning: unexpected `cfg` condition value
-  --> $DIR/mix.rs:21:7
+  --> $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: bar, foo
+   = note: expected values for `feature` are: foo
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:25:12
+  --> $DIR/mix.rs:26:12
    |
 LL | #[cfg_attr(uu, test)]
    |            ^^
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:34:10
+  --> $DIR/mix.rs:35:10
    |
 LL |     cfg!(widnows);
    |          ^^^^^^^ help: did you mean: `windows`
@@ -29,132 +37,138 @@ LL |     cfg!(widnows);
 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: bar, foo
+   = note: expected values for `feature` are: foo
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:40:10
+  --> $DIR/mix.rs:42:10
    |
 LL |     cfg!(xxx = "foo");
    |          ^^^^^^^^^^^
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:42:10
+  --> $DIR/mix.rs:44:10
    |
 LL |     cfg!(xxx);
    |          ^^^
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:44:14
+  --> $DIR/mix.rs:46:14
    |
 LL |     cfg!(any(xxx, windows));
    |              ^^^
 
 warning: unexpected `cfg` condition value
-  --> $DIR/mix.rs:46:14
+  --> $DIR/mix.rs:48:14
    |
 LL |     cfg!(any(feature = "bad", windows));
-   |              ^^^^^^^^^^-----
-   |                        |
-   |                        help: did you mean: `"bar"`
+   |              ^^^^^^^^^^^^^^^
    |
-   = note: expected values for `feature` are: bar, foo
+   = note: expected values for `feature` are: foo
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:48:23
+  --> $DIR/mix.rs:50:23
    |
 LL |     cfg!(any(windows, xxx));
    |                       ^^^
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:50:20
+  --> $DIR/mix.rs:52:20
    |
 LL |     cfg!(all(unix, xxx));
    |                    ^^^
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:52:14
+  --> $DIR/mix.rs:54:14
    |
 LL |     cfg!(all(aa, bb));
    |              ^^
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:52:18
+  --> $DIR/mix.rs:54:18
    |
 LL |     cfg!(all(aa, bb));
    |                  ^^
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:55:14
+  --> $DIR/mix.rs:57:14
    |
 LL |     cfg!(any(aa, bb));
    |              ^^
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:55:18
+  --> $DIR/mix.rs:57:18
    |
 LL |     cfg!(any(aa, bb));
    |                  ^^
 
 warning: unexpected `cfg` condition value
-  --> $DIR/mix.rs:58:20
+  --> $DIR/mix.rs:60:20
    |
 LL |     cfg!(any(unix, feature = "zebra"));
    |                    ^^^^^^^^^^^^^^^^^
    |
-   = note: expected values for `feature` are: bar, foo
+   = note: expected values for `feature` are: foo
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:60:14
+  --> $DIR/mix.rs:62:14
    |
 LL |     cfg!(any(xxx, feature = "zebra"));
    |              ^^^
 
 warning: unexpected `cfg` condition value
-  --> $DIR/mix.rs:60:19
+  --> $DIR/mix.rs:62:19
    |
 LL |     cfg!(any(xxx, feature = "zebra"));
    |                   ^^^^^^^^^^^^^^^^^
    |
-   = note: expected values for `feature` are: bar, foo
+   = note: expected values for `feature` are: foo
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:63:14
+  --> $DIR/mix.rs:65:14
    |
 LL |     cfg!(any(xxx, unix, xxx));
    |              ^^^
 
 warning: unexpected `cfg` condition name
-  --> $DIR/mix.rs:63:25
+  --> $DIR/mix.rs:65:25
    |
 LL |     cfg!(any(xxx, unix, xxx));
    |                         ^^^
 
 warning: unexpected `cfg` condition value
-  --> $DIR/mix.rs:66:14
+  --> $DIR/mix.rs:68:14
    |
 LL |     cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
    |              ^^^^^^^^^^^^^^^^^
    |
-   = note: expected values for `feature` are: bar, foo
+   = note: expected values for `feature` are: foo
 
 warning: unexpected `cfg` condition value
-  --> $DIR/mix.rs:66:33
+  --> $DIR/mix.rs:68:33
    |
 LL |     cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
    |                                 ^^^^^^^^^^^^^^^^^
    |
-   = note: expected values for `feature` are: bar, foo
+   = note: expected values for `feature` are: foo
 
 warning: unexpected `cfg` condition value
-  --> $DIR/mix.rs:66:52
+  --> $DIR/mix.rs:68:52
    |
 LL |     cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
    |                                                    ^^^^^^^^^^^^^^^^^
    |
-   = note: expected values for `feature` are: bar, foo
+   = note: expected values for `feature` are: foo
 
-warning: 23 warnings emitted
+warning: 25 warnings emitted