Remove deprecated --check-cfg names() and values() syntax

This commit is contained in:
Urgau 2023-11-16 18:41:45 +01:00
parent 9a942390bf
commit 3f0369e0f2
35 changed files with 182 additions and 406 deletions

View File

@ -10,8 +10,8 @@ use rustc_data_structures::sync::Lrc;
use rustc_errors::registry::Registry;
use rustc_errors::{ErrorGuaranteed, Handler};
use rustc_lint::LintStore;
use rustc_middle::ty;
use rustc_middle::util::Providers;
use rustc_middle::{bug, ty};
use rustc_parse::maybe_new_parser_from_source_str;
use rustc_query_impl::QueryCtxt;
use rustc_query_system::query::print_query_stack;
@ -104,7 +104,6 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
let exhaustive_values = !specs.is_empty();
let mut check_cfg = CheckCfg { exhaustive_names, exhaustive_values, ..CheckCfg::default() };
let mut old_syntax = None;
for s in specs {
let sess = ParseSess::with_silent_emitter(Some(format!(
"this error occurred on the command line: `--check-cfg={s}`"
@ -142,174 +141,101 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
expected_error();
};
let mut set_old_syntax = || {
// defaults are flipped for the old syntax
if old_syntax == None {
if !meta_item.has_name(sym::cfg) {
expected_error();
}
let mut names = Vec::new();
let mut values: FxHashSet<_> = Default::default();
let mut any_specified = false;
let mut values_specified = false;
let mut values_any_specified = false;
for arg in args {
if arg.is_word()
&& let Some(ident) = arg.ident()
{
if values_specified {
error!("`cfg()` names cannot be after values");
}
names.push(ident);
} else if arg.has_name(sym::any)
&& let Some(args) = arg.meta_item_list()
{
if any_specified {
error!("`any()` cannot be specified multiple times");
}
any_specified = true;
if !args.is_empty() {
error!("`any()` must be empty");
}
} else if arg.has_name(sym::values)
&& let Some(args) = arg.meta_item_list()
{
if names.is_empty() {
error!("`values()` cannot be specified before the names");
} else if values_specified {
error!("`values()` cannot be specified multiple times");
}
values_specified = true;
for arg in args {
if let Some(LitKind::Str(s, _)) = arg.lit().map(|lit| &lit.kind) {
values.insert(Some(*s));
} else if arg.has_name(sym::any)
&& let Some(args) = arg.meta_item_list()
{
if values_any_specified {
error!("`any()` in `values()` cannot be specified multiple times");
}
values_any_specified = true;
if !args.is_empty() {
error!("`any()` must be empty");
}
} else {
error!("`values()` arguments must be string literals or `any()`");
}
}
} else {
error!("`cfg()` arguments must be simple identifiers, `any()` or `values(...)`");
}
}
if values.is_empty() && !values_any_specified && !any_specified {
values.insert(None);
} else if !values.is_empty() && values_any_specified {
error!(
"`values()` arguments cannot specify string literals and `any()` at the same time"
);
}
if any_specified {
if names.is_empty() && values.is_empty() && !values_specified && !values_any_specified {
check_cfg.exhaustive_names = false;
check_cfg.exhaustive_values = false;
}
old_syntax = Some(true);
};
if meta_item.has_name(sym::names) {
set_old_syntax();
check_cfg.exhaustive_names = true;
for arg in args {
if arg.is_word()
&& let Some(ident) = arg.ident()
{
check_cfg.expecteds.entry(ident.name).or_insert(ExpectedValues::Any);
} else {
error!("`names()` arguments must be simple identifiers");
}
}
} else if meta_item.has_name(sym::values) {
set_old_syntax();
if let Some((name, values)) = args.split_first() {
if name.is_word()
&& let Some(ident) = name.ident()
{
let expected_values = check_cfg
.expecteds
.entry(ident.name)
.and_modify(|expected_values| match expected_values {
ExpectedValues::Some(_) => {}
ExpectedValues::Any => {
// handle the case where names(...) was done
// before values by changing to a list
*expected_values = ExpectedValues::Some(FxHashSet::default());
}
})
.or_insert_with(|| ExpectedValues::Some(FxHashSet::default()));
let ExpectedValues::Some(expected_values) = expected_values else {
bug!("`expected_values` should be a list a values")
};
for val in values {
if let Some(LitKind::Str(s, _)) = val.lit().map(|lit| &lit.kind) {
expected_values.insert(Some(*s));
} else {
error!("`values()` arguments must be string literals");
}
}
if values.is_empty() {
expected_values.insert(None);
}
} else {
error!("`values()` first argument must be a simple identifier");
}
} else if args.is_empty() {
check_cfg.exhaustive_values = true;
} else {
expected_error();
}
} else if meta_item.has_name(sym::cfg) {
old_syntax = Some(false);
let mut names = Vec::new();
let mut values: FxHashSet<_> = Default::default();
let mut any_specified = false;
let mut values_specified = false;
let mut values_any_specified = false;
for arg in args {
if arg.is_word()
&& let Some(ident) = arg.ident()
{
if values_specified {
error!("`cfg()` names cannot be after values");
}
names.push(ident);
} else if arg.has_name(sym::any)
&& let Some(args) = arg.meta_item_list()
{
if any_specified {
error!("`any()` cannot be specified multiple times");
}
any_specified = true;
if !args.is_empty() {
error!("`any()` must be empty");
}
} else if arg.has_name(sym::values)
&& let Some(args) = arg.meta_item_list()
{
if names.is_empty() {
error!("`values()` cannot be specified before the names");
} else if values_specified {
error!("`values()` cannot be specified multiple times");
}
values_specified = true;
for arg in args {
if let Some(LitKind::Str(s, _)) = arg.lit().map(|lit| &lit.kind) {
values.insert(Some(*s));
} else if arg.has_name(sym::any)
&& let Some(args) = arg.meta_item_list()
{
if values_any_specified {
error!("`any()` in `values()` cannot be specified multiple times");
}
values_any_specified = true;
if !args.is_empty() {
error!("`any()` must be empty");
}
} else {
error!("`values()` arguments must be string literals or `any()`");
}
}
} else {
error!(
"`cfg()` arguments must be simple identifiers, `any()` or `values(...)`"
);
}
}
if values.is_empty() && !values_any_specified && !any_specified {
values.insert(None);
} else if !values.is_empty() && values_any_specified {
error!(
"`values()` arguments cannot specify string literals and `any()` at the same time"
);
}
if any_specified {
if names.is_empty()
&& values.is_empty()
&& !values_specified
&& !values_any_specified
{
check_cfg.exhaustive_names = false;
} else {
error!("`cfg(any())` can only be provided in isolation");
}
} else {
for name in names {
check_cfg
.expecteds
.entry(name.name)
.and_modify(|v| match v {
ExpectedValues::Some(v) if !values_any_specified => {
v.extend(values.clone())
}
ExpectedValues::Some(_) => *v = ExpectedValues::Any,
ExpectedValues::Any => {}
})
.or_insert_with(|| {
if values_any_specified {
ExpectedValues::Any
} else {
ExpectedValues::Some(values.clone())
}
});
}
error!("`cfg(any())` can only be provided in isolation");
}
} else {
expected_error();
for name in names {
check_cfg
.expecteds
.entry(name.name)
.and_modify(|v| match v {
ExpectedValues::Some(v) if !values_any_specified => {
v.extend(values.clone())
}
ExpectedValues::Some(_) => *v = ExpectedValues::Any,
ExpectedValues::Any => {}
})
.or_insert_with(|| {
if values_any_specified {
ExpectedValues::Any
} else {
ExpectedValues::Some(values.clone())
}
});
}
}
}

View File

@ -190,70 +190,3 @@ fn shoot_lasers() {}
// the cfg(feature) list
fn write_shakespeare() {}
```
## The deprecated `names(...)` form
The `names(...)` form enables checking the names. This form uses a named list:
```bash
rustc --check-cfg 'names(name1, name2, ... nameN)'
```
where each `name` is a bare identifier (has no quotes). The order of the names is not significant.
If `--check-cfg names(...)` is specified at least once, then `rustc` will check all references to
condition names. `rustc` will check every `#[cfg]` attribute, `#[cfg_attr]` attribute, `cfg` clause
inside `#[link]` attribute and `cfg!(...)` call against the provided list of expected condition
names. If a name is not present in this list, then `rustc` will report an `unexpected_cfgs` lint
diagnostic. The default diagnostic level for this lint is `Warn`.
If `--check-cfg names(...)` is not specified, then `rustc` will not check references to condition
names.
`--check-cfg names(...)` may be specified more than once. The result is that the list of valid
condition names is merged across all options. It is legal for a condition name to be specified
more than once; redundantly specifying a condition name has no effect.
To enable checking condition names with an empty set of valid condition names, use the following
form. The parentheses are required.
```bash
rustc --check-cfg 'names()'
```
Note that `--check-cfg 'names()'` is _not_ equivalent to omitting the option entirely.
The first form enables checking condition names, while specifying that there are no valid
condition names (outside of the set of well-known names defined by `rustc`). Omitting the
`--check-cfg 'names(...)'` option does not enable checking condition names.
## The deprecated `values(...)` form
The `values(...)` form enables checking the values within list-valued conditions. It has this
form:
```bash
rustc --check-cfg `values(name, "value1", "value2", ... "valueN")'
```
where `name` is a bare identifier (has no quotes) and each `"value"` term is a quoted literal
string. `name` specifies the name of the condition, such as `feature` or `target_os`.
When the `values(...)` option is specified, `rustc` will check every `#[cfg(name = "value")]`
attribute, `#[cfg_attr(name = "value")]` attribute, `#[link(name = "a", cfg(name = "value"))]`
and `cfg!(name = "value")` call. It will check that the `"value"` specified is present in the
list of expected values. If `"value"` is not in it, then `rustc` will report an `unexpected_cfgs`
lint diagnostic. The default diagnostic level for this lint is `Warn`.
To enable checking of values, but to provide an empty set of valid values, use this form:
```bash
rustc --check-cfg `values(name)`
```
The `--check-cfg values(...)` option can be repeated, both for the same condition name and for
different names. If it is repeated for the same condition name, then the sets of values for that
condition are merged together.
If `values()` is specified, then `rustc` will enable the checking of well-known values defined
by itself. Note that it's necessary to specify the `values()` form to enable the checking of
well known values, specifying the other forms doesn't implicitly enable it.

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/exhaustive-names-values.rs:11:7
--> $DIR/exhaustive-names-values.rs:10:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
@ -8,7 +8,7 @@ LL | #[cfg(unknown_key = "value")]
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-names-values.rs:15:7
--> $DIR/exhaustive-names-values.rs:14:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
@ -18,13 +18,13 @@ LL | #[cfg(test = "value")]
= note: no expected value for `test`
warning: unexpected `cfg` condition name: `feature`
--> $DIR/exhaustive-names-values.rs:19:7
--> $DIR/exhaustive-names-values.rs:18:7
|
LL | #[cfg(feature = "unk")]
| ^^^^^^^^^^^^^^^
warning: unexpected `cfg` condition name: `feature`
--> $DIR/exhaustive-names-values.rs:26:7
--> $DIR/exhaustive-names-values.rs:25:7
|
LL | #[cfg(feature = "std")]
| ^^^^^^^^^^^^^^^

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/exhaustive-names-values.rs:11:7
--> $DIR/exhaustive-names-values.rs:10:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
@ -8,7 +8,7 @@ LL | #[cfg(unknown_key = "value")]
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-names-values.rs:15:7
--> $DIR/exhaustive-names-values.rs:14:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
@ -18,7 +18,7 @@ LL | #[cfg(test = "value")]
= note: no expected value for `test`
warning: unexpected `cfg` condition value: `unk`
--> $DIR/exhaustive-names-values.rs:19:7
--> $DIR/exhaustive-names-values.rs:18:7
|
LL | #[cfg(feature = "unk")]
| ^^^^^^^^^^^^^^^

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/exhaustive-names-values.rs:11:7
--> $DIR/exhaustive-names-values.rs:10:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
@ -8,7 +8,7 @@ LL | #[cfg(unknown_key = "value")]
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-names-values.rs:15:7
--> $DIR/exhaustive-names-values.rs:14:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
@ -18,7 +18,7 @@ LL | #[cfg(test = "value")]
= note: no expected value for `test`
warning: unexpected `cfg` condition value: `unk`
--> $DIR/exhaustive-names-values.rs:19:7
--> $DIR/exhaustive-names-values.rs:18:7
|
LL | #[cfg(feature = "unk")]
| ^^^^^^^^^^^^^^^

View File

@ -1,9 +1,8 @@
// Check warning for unexpected cfg in the code.
//
// check-pass
// revisions: empty_names_values empty_cfg feature full
// revisions: empty_cfg feature full
// compile-flags: -Z unstable-options
// [empty_names_values]compile-flags: --check-cfg=names() --check-cfg=values()
// [empty_cfg]compile-flags: --check-cfg=cfg()
// [feature]compile-flags: --check-cfg=cfg(feature,values("std"))
// [full]compile-flags: --check-cfg=cfg(feature,values("std")) --check-cfg=cfg()

View File

@ -1,9 +1,7 @@
// Check warning for unexpected cfg
//
// check-pass
// revisions: empty_names exhaustive_names
// [empty_names]compile-flags: --check-cfg=names() -Z unstable-options
// [exhaustive_names]compile-flags: --check-cfg=cfg() -Z unstable-options
// compile-flags: --check-cfg=cfg() -Z unstable-options
#[cfg(unknown_key = "value")]
//~^ WARNING unexpected `cfg` condition name

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/exhaustive-names.rs:8:7
--> $DIR/exhaustive-names.rs:6:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-values.rs:9:7
--> $DIR/exhaustive-values.rs:8:7
|
LL | #[cfg(test = "value")]
| ^^^^----------

View File

@ -1,13 +0,0 @@
warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-values.rs:9:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
| |
| help: remove the value
|
= note: no expected value for `test`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: 1 warning emitted

View File

@ -1,8 +1,7 @@
// Check warning for unexpected cfg value
//
// check-pass
// revisions: empty_values empty_cfg without_names
// [empty_values]compile-flags: --check-cfg=values() -Z unstable-options
// revisions: empty_cfg without_names
// [empty_cfg]compile-flags: --check-cfg=cfg() -Z unstable-options
// [without_names]compile-flags: --check-cfg=cfg(any()) -Z unstable-options

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-values.rs:9:7
--> $DIR/exhaustive-values.rs:8:7
|
LL | #[cfg(test = "value")]
| ^^^^----------

View File

@ -1,2 +0,0 @@
error: invalid `--check-cfg` argument: `names("NOT_IDENT")` (`names()` arguments must be simple identifiers)

View File

@ -1,7 +1,7 @@
// Check that invalid --check-cfg are rejected
//
// check-fail
// revisions: anything_else names_simple_ident values_simple_ident values_string_literals
// revisions: anything_else
// revisions: string_for_name_1 string_for_name_2 multiple_any multiple_values
// revisions: multiple_values_any not_empty_any not_empty_values_any
// revisions: values_any_missing_values values_any_before_ident ident_in_values_1
@ -10,9 +10,6 @@
//
// compile-flags: -Z unstable-options
// [anything_else]compile-flags: --check-cfg=anything_else(...)
// [names_simple_ident]compile-flags: --check-cfg=names("NOT_IDENT")
// [values_simple_ident]compile-flags: --check-cfg=values("NOT_IDENT")
// [values_string_literals]compile-flags: --check-cfg=values(test,12)
// [string_for_name_1]compile-flags: --check-cfg=cfg("NOT_IDENT")
// [string_for_name_2]compile-flags: --check-cfg=cfg(foo,"NOT_IDENT",bar)
// [multiple_any]compile-flags: --check-cfg=cfg(any(),any())

View File

@ -1,2 +0,0 @@
error: invalid `--check-cfg` argument: `values("NOT_IDENT")` (`values()` first argument must be a simple identifier)

View File

@ -1,2 +0,0 @@
error: invalid `--check-cfg` argument: `values(test,12)` (`values()` arguments must be string literals)

View File

@ -1,13 +1,10 @@
// 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
// This test checks the combination of well known names, the usage of cfg(),
// and that no implicit cfgs is added from --cfg while also testing that
// we correctly lint on the `cfg!` macro and `cfg_attr` attribute.
//
// check-pass
// revisions: names_values cfg
// compile-flags: --cfg feature="bar" --cfg unknown_name -Z unstable-options
// compile-flags: --check-cfg=cfg(names_values,cfg)
// [names_values]compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo")
// [cfg]compile-flags: --check-cfg=cfg(feature,values("foo"))
// compile-flags: --check-cfg=cfg(feature,values("foo"))
#[cfg(windows)]
fn do_windows_stuff() {}

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition name: `widnows`
--> $DIR/mix.rs:15:7
--> $DIR/mix.rs:12:7
|
LL | #[cfg(widnows)]
| ^^^^^^^ help: there is a config with a similar name: `windows`
@ -7,7 +7,7 @@ LL | #[cfg(widnows)]
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: (none)
--> $DIR/mix.rs:19:7
--> $DIR/mix.rs:16:7
|
LL | #[cfg(feature)]
| ^^^^^^^- help: specify a config value: `= "foo"`
@ -15,7 +15,7 @@ LL | #[cfg(feature)]
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value: `bar`
--> $DIR/mix.rs:26:7
--> $DIR/mix.rs:23:7
|
LL | #[cfg(feature = "bar")]
| ^^^^^^^^^^^^^^^
@ -23,7 +23,7 @@ LL | #[cfg(feature = "bar")]
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:30:7
--> $DIR/mix.rs:27:7
|
LL | #[cfg(feature = "zebra")]
| ^^^^^^^^^^^^^^^^^
@ -31,21 +31,21 @@ LL | #[cfg(feature = "zebra")]
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name: `uu`
--> $DIR/mix.rs:34:12
--> $DIR/mix.rs:31:12
|
LL | #[cfg_attr(uu, test)]
| ^^
|
= help: expected names are: `cfg`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `names_values`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition name: `widnows`
--> $DIR/mix.rs:43:10
--> $DIR/mix.rs:40:10
|
LL | cfg!(widnows);
| ^^^^^^^ help: there is a config with a similar name: `windows`
warning: unexpected `cfg` condition value: `bar`
--> $DIR/mix.rs:46:10
--> $DIR/mix.rs:43:10
|
LL | cfg!(feature = "bar");
| ^^^^^^^^^^^^^^^
@ -53,7 +53,7 @@ LL | cfg!(feature = "bar");
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:48:10
--> $DIR/mix.rs:45:10
|
LL | cfg!(feature = "zebra");
| ^^^^^^^^^^^^^^^^^
@ -61,25 +61,25 @@ LL | cfg!(feature = "zebra");
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:50:10
--> $DIR/mix.rs:47:10
|
LL | cfg!(xxx = "foo");
| ^^^^^^^^^^^
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:52:10
--> $DIR/mix.rs:49:10
|
LL | cfg!(xxx);
| ^^^
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:54:14
--> $DIR/mix.rs:51:14
|
LL | cfg!(any(xxx, windows));
| ^^^
warning: unexpected `cfg` condition value: `bad`
--> $DIR/mix.rs:56:14
--> $DIR/mix.rs:53:14
|
LL | cfg!(any(feature = "bad", windows));
| ^^^^^^^^^^^^^^^
@ -87,43 +87,43 @@ LL | cfg!(any(feature = "bad", windows));
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:58:23
--> $DIR/mix.rs:55:23
|
LL | cfg!(any(windows, xxx));
| ^^^
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:60:20
--> $DIR/mix.rs:57:20
|
LL | cfg!(all(unix, xxx));
| ^^^
warning: unexpected `cfg` condition name: `aa`
--> $DIR/mix.rs:62:14
--> $DIR/mix.rs:59:14
|
LL | cfg!(all(aa, bb));
| ^^
warning: unexpected `cfg` condition name: `bb`
--> $DIR/mix.rs:62:18
--> $DIR/mix.rs:59:18
|
LL | cfg!(all(aa, bb));
| ^^
warning: unexpected `cfg` condition name: `aa`
--> $DIR/mix.rs:65:14
--> $DIR/mix.rs:62:14
|
LL | cfg!(any(aa, bb));
| ^^
warning: unexpected `cfg` condition name: `bb`
--> $DIR/mix.rs:65:18
--> $DIR/mix.rs:62:18
|
LL | cfg!(any(aa, bb));
| ^^
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:68:20
--> $DIR/mix.rs:65:20
|
LL | cfg!(any(unix, feature = "zebra"));
| ^^^^^^^^^^^^^^^^^
@ -131,13 +131,13 @@ LL | cfg!(any(unix, feature = "zebra"));
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:70:14
--> $DIR/mix.rs:67:14
|
LL | cfg!(any(xxx, feature = "zebra"));
| ^^^
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:70:19
--> $DIR/mix.rs:67:19
|
LL | cfg!(any(xxx, feature = "zebra"));
| ^^^^^^^^^^^^^^^^^
@ -145,19 +145,19 @@ LL | cfg!(any(xxx, feature = "zebra"));
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:73:14
--> $DIR/mix.rs:70:14
|
LL | cfg!(any(xxx, unix, xxx));
| ^^^
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:73:25
--> $DIR/mix.rs:70:25
|
LL | cfg!(any(xxx, unix, xxx));
| ^^^
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:76:14
--> $DIR/mix.rs:73:14
|
LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
| ^^^^^^^^^^^^^^^^^
@ -165,7 +165,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:76:33
--> $DIR/mix.rs:73:33
|
LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
| ^^^^^^^^^^^^^^^^^
@ -173,7 +173,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:76:52
--> $DIR/mix.rs:73:52
|
LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
| ^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-expected-values.rs:12:7
--> $DIR/no-expected-values.rs:11:7
|
LL | #[cfg(feature = "foo")]
| ^^^^^^^--------
@ -10,7 +10,7 @@ LL | #[cfg(feature = "foo")]
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-expected-values.rs:16:7
--> $DIR/no-expected-values.rs:15:7
|
LL | #[cfg(test = "foo")]
| ^^^^--------

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-expected-values.rs:12:7
--> $DIR/no-expected-values.rs:11:7
|
LL | #[cfg(feature = "foo")]
| ^^^^^^^--------
@ -10,7 +10,7 @@ LL | #[cfg(feature = "foo")]
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-expected-values.rs:16:7
--> $DIR/no-expected-values.rs:15:7
|
LL | #[cfg(test = "foo")]
| ^^^^--------

View File

@ -1,10 +1,9 @@
// Check that we detect unexpected value when none are allowed
//
// check-pass
// revisions: values simple mixed empty
// revisions: simple mixed empty
// compile-flags: -Z unstable-options
// compile-flags: --check-cfg=cfg(values,simple,mixed,empty)
// [values]compile-flags: --check-cfg=values(test) --check-cfg=values(feature)
// [simple]compile-flags: --check-cfg=cfg(test) --check-cfg=cfg(feature)
// [mixed]compile-flags: --check-cfg=cfg(test,feature)
// [empty]compile-flags: --check-cfg=cfg(test,feature,values())

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-expected-values.rs:12:7
--> $DIR/no-expected-values.rs:11:7
|
LL | #[cfg(feature = "foo")]
| ^^^^^^^--------
@ -10,7 +10,7 @@ LL | #[cfg(feature = "foo")]
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-expected-values.rs:16:7
--> $DIR/no-expected-values.rs:15:7
|
LL | #[cfg(test = "foo")]
| ^^^^--------

View File

@ -1,23 +0,0 @@
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-expected-values.rs:12:7
|
LL | #[cfg(feature = "foo")]
| ^^^^^^^--------
| |
| help: remove the value
|
= note: no expected value for `feature`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-expected-values.rs:16:7
|
LL | #[cfg(test = "foo")]
| ^^^^--------
| |
| help: remove the value
|
= note: no expected value for `test`
warning: 2 warnings emitted

View File

@ -1,19 +0,0 @@
warning: unexpected `cfg` condition value: (none)
--> $DIR/order-independant.rs:8:7
|
LL | #[cfg(a)]
| ^- help: specify a config value: `= "b"`
|
= note: expected values for `a` are: `b`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `unk`
--> $DIR/order-independant.rs:12:7
|
LL | #[cfg(a = "unk")]
| ^^^^^^^^^
|
= note: expected values for `a` are: `b`
warning: 2 warnings emitted

View File

@ -1,19 +0,0 @@
warning: unexpected `cfg` condition value: (none)
--> $DIR/order-independant.rs:8:7
|
LL | #[cfg(a)]
| ^- help: specify a config value: `= "b"`
|
= note: expected values for `a` are: `b`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `unk`
--> $DIR/order-independant.rs:12:7
|
LL | #[cfg(a = "unk")]
| ^^^^^^^^^
|
= note: expected values for `a` are: `b`
warning: 2 warnings emitted

View File

@ -1,12 +1,13 @@
// check-pass
// revisions: names_before names_after
//
// revisions: values_before values_after
// compile-flags: -Z unstable-options
// compile-flags: --check-cfg=names(names_before,names_after)
// [names_before]compile-flags: --check-cfg=names(a) --check-cfg=values(a,"b")
// [names_after]compile-flags: --check-cfg=values(a,"b") --check-cfg=names(a)
// compile-flags: --check-cfg=cfg(values_before,values_after)
//
// [values_before]compile-flags: --check-cfg=cfg(a,values("b")) --check-cfg=cfg(a)
// [values_after]compile-flags: --check-cfg=cfg(a) --check-cfg=cfg(a,values("b"))
#[cfg(a)]
//~^ WARNING unexpected `cfg` condition value
fn my_cfg() {}
#[cfg(a = "unk")]

View File

@ -0,0 +1,11 @@
warning: unexpected `cfg` condition value: `unk`
--> $DIR/order-independant.rs:13:7
|
LL | #[cfg(a = "unk")]
| ^^^^^^^^^
|
= note: expected values for `a` are: (none), `b`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: 1 warning emitted

View File

@ -0,0 +1,11 @@
warning: unexpected `cfg` condition value: `unk`
--> $DIR/order-independant.rs:13:7
|
LL | #[cfg(a = "unk")]
| ^^^^^^^^^
|
= note: expected values for `a` are: (none), `b`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: 1 warning emitted

View File

@ -1,10 +0,0 @@
warning: unexpected `cfg` condition name: `widnows`
--> $DIR/unexpected-cfg-name.rs:9:7
|
LL | #[cfg(widnows)]
| ^^^^^^^ help: there is a config with a similar name: `windows`
|
= note: `#[warn(unexpected_cfgs)]` on by default
warning: 1 warning emitted

View File

@ -1,10 +1,7 @@
// Check warning for unexpected configuration name
//
// check-pass
// revisions: names exhaustive
// compile-flags: --check-cfg=cfg(names,exhaustive)
// [names]compile-flags: --check-cfg=names() -Z unstable-options
// [exhaustive]compile-flags: --check-cfg=cfg() -Z unstable-options
// compile-flags: --check-cfg=cfg() -Z unstable-options
#[cfg(widnows)]
//~^ WARNING unexpected `cfg` condition name

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition name: `widnows`
--> $DIR/unexpected-cfg-name.rs:9:7
--> $DIR/unexpected-cfg-name.rs:6:7
|
LL | #[cfg(widnows)]
| ^^^^^^^ help: there is a config with a similar name: `windows`

View File

@ -1,10 +1,8 @@
// Check for unexpected configuration value in the code.
//
// check-pass
// revisions: values cfg
// compile-flags: -Z unstable-options
// [values]compile-flags: --check-cfg=values(feature,"serde","full")
// [cfg]compile-flags: --check-cfg=cfg(feature,values("serde","full"))
// compile-flags: --cfg=feature="rand" -Z unstable-options
// compile-flags: --check-cfg=cfg(feature,values("serde","full"))
#[cfg(feature = "sedre")]
//~^ WARNING unexpected `cfg` condition value

View File

@ -1,5 +1,5 @@
warning: unexpected `cfg` condition value: `sedre`
--> $DIR/unexpected-cfg-value.rs:9:7
--> $DIR/unexpected-cfg-value.rs:7:7
|
LL | #[cfg(feature = "sedre")]
| ^^^^^^^^^^-------
@ -10,7 +10,7 @@ LL | #[cfg(feature = "sedre")]
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value: `rand`
--> $DIR/unexpected-cfg-value.rs:16:7
--> $DIR/unexpected-cfg-value.rs:14:7
|
LL | #[cfg(feature = "rand")]
| ^^^^^^^^^^^^^^^^

View File

@ -2,7 +2,7 @@
//
// check-pass
// needs-llvm-components: x86
// compile-flags: --crate-type=lib --check-cfg=values() --target={{src-base}}/check-cfg/my-awesome-platform.json -Z unstable-options
// compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json -Z unstable-options
#![feature(lang_items, no_core, auto_traits)]
#![no_core]

View File

@ -1,3 +1,3 @@
// compile-flags: --check-cfg "names()"
// compile-flags: --check-cfg "cfg()"
fn main() {}