-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #119473 - Urgau:check-cfg-explicit-none, r=petrochenkov
Add explicit `none()` value variant in check-cfg This PR adds an explicit none value variant in check-cfg values: `values(none())`. Currently the only way to define the none variant is with an empty `values()` which means that if someone has a cfg that takes none and strings they need to use two invocations: `--check-cfg=cfg(foo) --check-cfg=cfg(foo, values("bar"))`. Which would now be `--check-cfg=cfg(foo, values(none(),"bar"))`, this is simpler and easier to understand. `--check-cfg=cfg(foo)`, `--check-cfg=cfg(foo, values())` and `--check-cfg=cfg(foo, values(none()))` would be equivalent. *Another motivation for doing this is to make empty `values()` actually means no-values, but this is orthogonal to this PR and adding `none()` is sufficient in it-self.* `@rustbot` label +F-check-cfg r? `@petrochenkov`
- Loading branch information
Showing
12 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
error: invalid `--check-cfg` argument: `cfg(none())` (`cfg()` arguments must be simple identifiers, `any()` or `values(...)`) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
error: invalid `--check-cfg` argument: `cfg(foo,values(bar))` (`values()` arguments must be string literals or `any()`) | ||
error: invalid `--check-cfg` argument: `cfg(foo,values(bar))` (`values()` arguments must be string literals, `none()` or `any()`) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
error: invalid `--check-cfg` argument: `cfg(foo,values("bar",bar,"bar"))` (`values()` arguments must be string literals or `any()`) | ||
error: invalid `--check-cfg` argument: `cfg(foo,values("bar",bar,"bar"))` (`values()` arguments must be string literals, `none()` or `any()`) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
error: invalid `--check-cfg` argument: `cfg(foo,values(none("test")))` (`none()` must be empty) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/ui/check-cfg/invalid-arguments.unknown_meta_item_3.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
error: invalid `--check-cfg` argument: `cfg(foo,values(test()))` (`values()` arguments must be string literals or `any()`) | ||
error: invalid `--check-cfg` argument: `cfg(foo,values(test()))` (`values()` arguments must be string literals, `none()` or `any()`) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
warning: unexpected `cfg` condition value: `too` | ||
--> $DIR/values-none.rs:11:7 | ||
| | ||
LL | #[cfg(foo = "too")] | ||
| ^^^-------- | ||
| | | ||
| help: remove the value | ||
| | ||
= note: no expected value for `foo` | ||
= help: to expect this configuration use `--check-cfg=cfg(foo, values("too"))` | ||
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration | ||
= note: `#[warn(unexpected_cfgs)]` on by default | ||
|
||
warning: unexpected `cfg` condition value: `bar` | ||
--> $DIR/values-none.rs:16:7 | ||
| | ||
LL | #[cfg(foo = "bar")] | ||
| ^^^-------- | ||
| | | ||
| help: remove the value | ||
| | ||
= note: no expected value for `foo` | ||
= help: to expect this configuration use `--check-cfg=cfg(foo, values("bar"))` | ||
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration | ||
|
||
warning: 2 warnings emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
warning: unexpected `cfg` condition value: `too` | ||
--> $DIR/values-none.rs:11:7 | ||
| | ||
LL | #[cfg(foo = "too")] | ||
| ^^^-------- | ||
| | | ||
| help: remove the value | ||
| | ||
= note: no expected value for `foo` | ||
= help: to expect this configuration use `--check-cfg=cfg(foo, values("too"))` | ||
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration | ||
= note: `#[warn(unexpected_cfgs)]` on by default | ||
|
||
warning: unexpected `cfg` condition value: `bar` | ||
--> $DIR/values-none.rs:16:7 | ||
| | ||
LL | #[cfg(foo = "bar")] | ||
| ^^^-------- | ||
| | | ||
| help: remove the value | ||
| | ||
= note: no expected value for `foo` | ||
= help: to expect this configuration use `--check-cfg=cfg(foo, values("bar"))` | ||
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration | ||
|
||
warning: 2 warnings emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// check-pass | ||
// | ||
// revisions: explicit implicit | ||
// compile-flags: -Zunstable-options | ||
// [explicit]compile-flags: --check-cfg=cfg(foo,values(none())) | ||
// [implicit]compile-flags: --check-cfg=cfg(foo) | ||
// [simple] compile-flags: --check-cfg=cfg(foo,values(none(),"too")) | ||
// [concat_1]compile-flags: --check-cfg=cfg(foo) --check-cfg=cfg(foo,values("too")) | ||
// [concat_2]compile-flags: --check-cfg=cfg(foo,values("too")) --check-cfg=cfg(foo) | ||
|
||
#[cfg(foo = "too")] | ||
//[explicit]~^ WARNING unexpected `cfg` condition value | ||
//[implicit]~^^ WARNING unexpected `cfg` condition value | ||
fn foo_too() {} | ||
|
||
#[cfg(foo = "bar")] | ||
//~^ WARNING unexpected `cfg` condition value | ||
fn foo_bar() {} | ||
|
||
#[cfg(foo)] | ||
fn foo() {} | ||
|
||
fn main() {} |