Skip to content

Commit fc78d78

Browse files
committed
MCP636: Adapt check-cfg tests to the new syntax
1 parent e5e95eb commit fc78d78

File tree

68 files changed

+749
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+749
-124
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// check-fail
2-
// compile-flags: --check-cfg=names()
2+
// compile-flags: --check-cfg=cfg()

tests/rustdoc-ui/check-cfg/check-cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// check-pass
2-
// compile-flags: --check-cfg=names() -Z unstable-options
2+
// compile-flags: --check-cfg=cfg() -Z unstable-options
33

44
/// uniz is nor a builtin nor pass as arguments so is unexpected
55
#[cfg(uniz)]

tests/rustdoc-ui/doctest/check-cfg-test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// check-pass
2-
// compile-flags: --test --nocapture --check-cfg=values(feature,"test") -Z unstable-options
2+
// compile-flags: --test --nocapture --check-cfg=cfg(feature,values("test")) -Z unstable-options
33
// normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
44
// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
55
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"

tests/ui/check-cfg/allow-at-crate-level.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test check that #![allow(unexpected_cfgs)] works with --cfg
22
//
33
// check-pass
4-
// compile-flags: --cfg=unexpected --check-cfg=names() -Z unstable-options
4+
// compile-flags: --cfg=unexpected --check-cfg=cfg() -Z unstable-options
55

66
#![allow(unexpected_cfgs)]
77

tests/ui/check-cfg/allow-macro-cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test check that local #[allow(unexpected_cfgs)] works
22
//
33
// check-pass
4-
// compile-flags:--check-cfg=names() -Z unstable-options
4+
// compile-flags: --check-cfg=cfg() -Z unstable-options
55

66
#[allow(unexpected_cfgs)]
77
fn foo() {

tests/ui/check-cfg/allow-same-level.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test check that #[allow(unexpected_cfgs)] doesn't work if put on the same level
22
//
33
// check-pass
4-
// compile-flags:--check-cfg=names() -Z unstable-options
4+
// compile-flags: --check-cfg=cfg() -Z unstable-options
55

66
#[allow(unexpected_cfgs)]
77
#[cfg(FALSE)]

tests/ui/check-cfg/allow-top-level.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test check that a top-level #![allow(unexpected_cfgs)] works
22
//
33
// check-pass
4-
// compile-flags:--check-cfg=names() -Z unstable-options
4+
// compile-flags: --check-cfg=cfg() -Z unstable-options
55

66
#![allow(unexpected_cfgs)]
77

tests/ui/check-cfg/allow-upper-level.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test check that #[allow(unexpected_cfgs)] work if put on an upper level
22
//
33
// check-pass
4-
// compile-flags:--check-cfg=names() -Z unstable-options
4+
// compile-flags: --check-cfg=cfg() -Z unstable-options
55

66
#[allow(unexpected_cfgs)]
77
mod aa {

tests/ui/check-cfg/compact-names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test check that we correctly emit an warning for compact cfg
22
//
33
// check-pass
4-
// compile-flags:--check-cfg=names() -Z unstable-options
4+
// compile-flags: --check-cfg=cfg() -Z unstable-options
55

66
#![feature(cfg_target_compact)]
77

tests/ui/check-cfg/compact-values.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test check that we correctly emit an warning for compact cfg
22
//
33
// check-pass
4-
// compile-flags:--check-cfg=values() -Z unstable-options
4+
// compile-flags: --check-cfg=cfg() -Z unstable-options
55

66
#![feature(cfg_target_compact)]
77

tests/ui/check-cfg/concat-values.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
// compile-flags: -Z unstable-options
3+
// compile-flags: --check-cfg=cfg(my_cfg,values("foo")) --check-cfg=cfg(my_cfg,values("bar"))
4+
5+
#[cfg(my_cfg)]
6+
//~^ WARNING unexpected `cfg` condition value
7+
fn my_cfg() {}
8+
9+
#[cfg(my_cfg = "unk")]
10+
//~^ WARNING unexpected `cfg` condition value
11+
fn my_cfg() {}
12+
13+
fn main() {}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
warning: unexpected `cfg` condition value: (none)
2+
--> $DIR/concat-values.rs:5:7
3+
|
4+
LL | #[cfg(my_cfg)]
5+
| ^^^^^^
6+
|
7+
= note: expected values for `my_cfg` are: `bar`, `foo`
8+
= note: `#[warn(unexpected_cfgs)]` on by default
9+
10+
warning: unexpected `cfg` condition value: `unk`
11+
--> $DIR/concat-values.rs:9:7
12+
|
13+
LL | #[cfg(my_cfg = "unk")]
14+
| ^^^^^^^^^^^^^^
15+
|
16+
= note: expected values for `my_cfg` are: `bar`, `foo`
17+
18+
warning: 2 warnings emitted
19+

tests/ui/check-cfg/diagnotics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// check-pass
2-
// compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --check-cfg=values(no_values) -Z unstable-options
2+
// compile-flags: --check-cfg=cfg(feature,values("foo")) --check-cfg=cfg(no_values) -Z unstable-options
33

44
#[cfg(featur)]
55
//~^ WARNING unexpected `cfg` condition name

tests/ui/check-cfg/empty-names.rs

-10
This file was deleted.

tests/ui/check-cfg/empty-values.rs

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
warning: unexpected `cfg` condition name: `unknown_key`
2+
--> $DIR/exhaustive-names-values.rs:12:7
3+
|
4+
LL | #[cfg(unknown_key = "value")]
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= 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`
8+
= note: `#[warn(unexpected_cfgs)]` on by default
9+
10+
warning: unexpected `cfg` condition value: `value`
11+
--> $DIR/exhaustive-names-values.rs:16:7
12+
|
13+
LL | #[cfg(test = "value")]
14+
| ^^^^----------
15+
| |
16+
| help: remove the value
17+
|
18+
= note: no expected value for `test`
19+
20+
warning: unexpected `empty_cfg` as condition name
21+
|
22+
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names
23+
24+
warning: 3 warnings emitted
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
warning: unexpected `cfg` condition name: `unknown_key`
2+
--> $DIR/exhaustive-names-values.rs:12:7
3+
|
4+
LL | #[cfg(unknown_key = "value")]
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= 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`
8+
= note: `#[warn(unexpected_cfgs)]` on by default
9+
10+
warning: unexpected `cfg` condition value: `value`
11+
--> $DIR/exhaustive-names-values.rs:16:7
12+
|
13+
LL | #[cfg(test = "value")]
14+
| ^^^^----------
15+
| |
16+
| help: remove the value
17+
|
18+
= note: no expected value for `test`
19+
20+
warning: unexpected `empty_names_values` as condition name
21+
|
22+
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names
23+
24+
warning: 3 warnings emitted
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
warning: unexpected `cfg` condition name: `unknown_key`
2+
--> $DIR/exhaustive-names-values.rs:12:7
3+
|
4+
LL | #[cfg(unknown_key = "value")]
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= 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`
8+
= note: `#[warn(unexpected_cfgs)]` on by default
9+
10+
warning: unexpected `cfg` condition value: `value`
11+
--> $DIR/exhaustive-names-values.rs:16:7
12+
|
13+
LL | #[cfg(test = "value")]
14+
| ^^^^----------
15+
| |
16+
| help: remove the value
17+
|
18+
= note: no expected value for `test`
19+
20+
warning: unexpected `cfg` condition value: `unk`
21+
--> $DIR/exhaustive-names-values.rs:20:7
22+
|
23+
LL | #[cfg(feature = "unk")]
24+
| ^^^^^^^^^^^^^^^
25+
|
26+
= note: expected values for `feature` are: `std`
27+
28+
warning: unexpected condition value `` for condition name `feature`
29+
|
30+
= help: was set with `--cfg` but isn't in the `--check-cfg` expected values
31+
32+
warning: 4 warnings emitted
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
warning: unexpected `cfg` condition name: `unknown_key`
2+
--> $DIR/exhaustive-names-values.rs:12:7
3+
|
4+
LL | #[cfg(unknown_key = "value")]
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= 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`
8+
= note: `#[warn(unexpected_cfgs)]` on by default
9+
10+
warning: unexpected `cfg` condition value: `value`
11+
--> $DIR/exhaustive-names-values.rs:16:7
12+
|
13+
LL | #[cfg(test = "value")]
14+
| ^^^^----------
15+
| |
16+
| help: remove the value
17+
|
18+
= note: no expected value for `test`
19+
20+
warning: unexpected `cfg` condition value: `unk`
21+
--> $DIR/exhaustive-names-values.rs:20:7
22+
|
23+
LL | #[cfg(feature = "unk")]
24+
| ^^^^^^^^^^^^^^^
25+
|
26+
= note: expected values for `feature` are: `std`
27+
28+
warning: unexpected `full` as condition name
29+
|
30+
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names
31+
32+
warning: 4 warnings emitted
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Check warning for unexpected cfg in the code and in the CLI
2+
// arguments (here the revision cfg).
3+
//
4+
// check-pass
5+
// revisions: empty_names_values empty_cfg feature full
6+
// compile-flags: -Z unstable-options
7+
// [empty_names_values]compile-flags: --check-cfg=names() --check-cfg=values()
8+
// [empty_cfg]compile-flags: --check-cfg=cfg()
9+
// [feature]compile-flags: --check-cfg=cfg(feature,values("std"))
10+
// [full]compile-flags: --check-cfg=cfg(feature,values("std")) --check-cfg=cfg()
11+
12+
#[cfg(unknown_key = "value")]
13+
//~^ WARNING unexpected `cfg` condition name
14+
pub fn f() {}
15+
16+
#[cfg(test = "value")]
17+
//~^ WARNING unexpected `cfg` condition value
18+
pub fn f() {}
19+
20+
#[cfg(feature = "unk")]
21+
//[feature]~^ WARNING unexpected `cfg` condition value
22+
//[full]~^^ WARNING unexpected `cfg` condition value
23+
pub fn feat() {}
24+
25+
#[cfg(feature = "std")]
26+
pub fn feat() {}
27+
28+
#[cfg(windows)]
29+
pub fn win() {}
30+
31+
#[cfg(unix)]
32+
pub fn unix() {}
33+
34+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
warning: unexpected `cfg` condition name: `unknown_key`
2-
--> $DIR/empty-names.rs:6:7
2+
--> $DIR/exhaustive-names.rs:8:7
33
|
44
LL | #[cfg(unknown_key = "value")]
55
| ^^^^^^^^^^^^^^^^^^^^^
66
|
77
= 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`
88
= note: `#[warn(unexpected_cfgs)]` on by default
99

10-
warning: 1 warning emitted
10+
warning: unexpected `empty_names` as condition name
11+
|
12+
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names
13+
14+
warning: 2 warnings emitted
1115

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
warning: unexpected `cfg` condition name: `unknown_key`
2+
--> $DIR/exhaustive-names.rs:8:7
3+
|
4+
LL | #[cfg(unknown_key = "value")]
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= 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`
8+
= note: `#[warn(unexpected_cfgs)]` on by default
9+
10+
warning: unexpected `exhaustive_names` as condition name
11+
|
12+
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names
13+
14+
warning: 2 warnings emitted
15+
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Check warning for unexpected cfg
2+
//
3+
// check-pass
4+
// revisions: empty_names exhaustive_names
5+
// [empty_names]compile-flags: --check-cfg=names() -Z unstable-options
6+
// [exhaustive_names]compile-flags: --check-cfg=cfg() -Z unstable-options
7+
8+
#[cfg(unknown_key = "value")]
9+
//~^ WARNING unexpected `cfg` condition name
10+
pub fn f() {}
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
warning: unexpected `cfg` condition value: `value`
2+
--> $DIR/exhaustive-values.rs:9:7
3+
|
4+
LL | #[cfg(test = "value")]
5+
| ^^^^----------
6+
| |
7+
| help: remove the value
8+
|
9+
= note: no expected value for `test`
10+
= note: `#[warn(unexpected_cfgs)]` on by default
11+
12+
warning: unexpected `empty_cfg` as condition name
13+
|
14+
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names
15+
16+
warning: 2 warnings emitted
17+

tests/ui/check-cfg/empty-values.stderr tests/ui/check-cfg/exhaustive-values.empty_values.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unexpected `cfg` condition value: `value`
2-
--> $DIR/empty-values.rs:6:7
2+
--> $DIR/exhaustive-values.rs:9:7
33
|
44
LL | #[cfg(test = "value")]
55
| ^^^^----------
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Check warning for unexpected cfg value
2+
//
3+
// check-pass
4+
// revisions: empty_values empty_cfg without_names
5+
// [empty_values]compile-flags: --check-cfg=values() -Z unstable-options
6+
// [empty_cfg]compile-flags: --check-cfg=cfg() -Z unstable-options
7+
// [without_names]compile-flags: --check-cfg=cfg(any()) -Z unstable-options
8+
9+
#[cfg(test = "value")]
10+
//~^ WARNING unexpected `cfg` condition value
11+
pub fn f() {}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
warning: unexpected `cfg` condition value: `value`
2+
--> $DIR/exhaustive-values.rs:9:7
3+
|
4+
LL | #[cfg(test = "value")]
5+
| ^^^^----------
6+
| |
7+
| help: remove the value
8+
|
9+
= note: no expected value for `test`
10+
= note: `#[warn(unexpected_cfgs)]` on by default
11+
12+
warning: 1 warning emitted
13+

0 commit comments

Comments
 (0)