Skip to content

Commit

Permalink
MCP636: Adapt check-cfg tests to the new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Oct 13, 2023
1 parent e5e95eb commit fc78d78
Show file tree
Hide file tree
Showing 68 changed files with 749 additions and 124 deletions.
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// check-fail
// compile-flags: --check-cfg=names()
// compile-flags: --check-cfg=cfg()
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/check-cfg/check-cfg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// check-pass
// compile-flags: --check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=cfg() -Z unstable-options

/// uniz is nor a builtin nor pass as arguments so is unexpected
#[cfg(uniz)]
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/doctest/check-cfg-test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// check-pass
// compile-flags: --test --nocapture --check-cfg=values(feature,"test") -Z unstable-options
// compile-flags: --test --nocapture --check-cfg=cfg(feature,values("test")) -Z unstable-options
// normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-at-crate-level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that #![allow(unexpected_cfgs)] works with --cfg
//
// check-pass
// compile-flags: --cfg=unexpected --check-cfg=names() -Z unstable-options
// compile-flags: --cfg=unexpected --check-cfg=cfg() -Z unstable-options

#![allow(unexpected_cfgs)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-macro-cfg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that local #[allow(unexpected_cfgs)] works
//
// check-pass
// compile-flags:--check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=cfg() -Z unstable-options

#[allow(unexpected_cfgs)]
fn foo() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-same-level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// compile-flags: --check-cfg=cfg() -Z unstable-options

#[allow(unexpected_cfgs)]
#[cfg(FALSE)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-top-level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that a top-level #![allow(unexpected_cfgs)] works
//
// check-pass
// compile-flags:--check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=cfg() -Z unstable-options

#![allow(unexpected_cfgs)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/allow-upper-level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that #[allow(unexpected_cfgs)] work if put on an upper level
//
// check-pass
// compile-flags:--check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=cfg() -Z unstable-options

#[allow(unexpected_cfgs)]
mod aa {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/compact-names.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that we correctly emit an warning for compact cfg
//
// check-pass
// compile-flags:--check-cfg=names() -Z unstable-options
// compile-flags: --check-cfg=cfg() -Z unstable-options

#![feature(cfg_target_compact)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/check-cfg/compact-values.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test check that we correctly emit an warning for compact cfg
//
// check-pass
// compile-flags:--check-cfg=values() -Z unstable-options
// compile-flags: --check-cfg=cfg() -Z unstable-options

#![feature(cfg_target_compact)]

Expand Down
13 changes: 13 additions & 0 deletions tests/ui/check-cfg/concat-values.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// check-pass
// compile-flags: -Z unstable-options
// compile-flags: --check-cfg=cfg(my_cfg,values("foo")) --check-cfg=cfg(my_cfg,values("bar"))

#[cfg(my_cfg)]
//~^ WARNING unexpected `cfg` condition value
fn my_cfg() {}

#[cfg(my_cfg = "unk")]
//~^ WARNING unexpected `cfg` condition value
fn my_cfg() {}

fn main() {}
19 changes: 19 additions & 0 deletions tests/ui/check-cfg/concat-values.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
warning: unexpected `cfg` condition value: (none)
--> $DIR/concat-values.rs:5:7
|
LL | #[cfg(my_cfg)]
| ^^^^^^
|
= note: expected values for `my_cfg` are: `bar`, `foo`
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value: `unk`
--> $DIR/concat-values.rs:9:7
|
LL | #[cfg(my_cfg = "unk")]
| ^^^^^^^^^^^^^^
|
= note: expected values for `my_cfg` are: `bar`, `foo`

warning: 2 warnings emitted

2 changes: 1 addition & 1 deletion tests/ui/check-cfg/diagnotics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// check-pass
// compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --check-cfg=values(no_values) -Z unstable-options
// compile-flags: --check-cfg=cfg(feature,values("foo")) --check-cfg=cfg(no_values) -Z unstable-options

#[cfg(featur)]
//~^ WARNING unexpected `cfg` condition name
Expand Down
10 changes: 0 additions & 10 deletions tests/ui/check-cfg/empty-names.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/check-cfg/empty-values.rs

This file was deleted.

25 changes: 25 additions & 0 deletions tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/exhaustive-names-values.rs:12:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= 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`
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-names-values.rs:16:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
| |
| help: remove the value
|
= note: no expected value for `test`

warning: unexpected `empty_cfg` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 3 warnings emitted

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/exhaustive-names-values.rs:12:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= 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`
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-names-values.rs:16:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
| |
| help: remove the value
|
= note: no expected value for `test`

warning: unexpected `empty_names_values` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 3 warnings emitted

33 changes: 33 additions & 0 deletions tests/ui/check-cfg/exhaustive-names-values.feature.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/exhaustive-names-values.rs:12:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= 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`
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-names-values.rs:16:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
| |
| help: remove the value
|
= note: no expected value for `test`

warning: unexpected `cfg` condition value: `unk`
--> $DIR/exhaustive-names-values.rs:20:7
|
LL | #[cfg(feature = "unk")]
| ^^^^^^^^^^^^^^^
|
= note: expected values for `feature` are: `std`

warning: unexpected condition value `` for condition name `feature`
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected values

warning: 4 warnings emitted

33 changes: 33 additions & 0 deletions tests/ui/check-cfg/exhaustive-names-values.full.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/exhaustive-names-values.rs:12:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= 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`
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value: `value`
--> $DIR/exhaustive-names-values.rs:16:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
| |
| help: remove the value
|
= note: no expected value for `test`

warning: unexpected `cfg` condition value: `unk`
--> $DIR/exhaustive-names-values.rs:20:7
|
LL | #[cfg(feature = "unk")]
| ^^^^^^^^^^^^^^^
|
= note: expected values for `feature` are: `std`

warning: unexpected `full` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 4 warnings emitted

34 changes: 34 additions & 0 deletions tests/ui/check-cfg/exhaustive-names-values.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Check warning for unexpected cfg in the code and in the CLI
// arguments (here the revision cfg).
//
// check-pass
// revisions: empty_names_values 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()

#[cfg(unknown_key = "value")]
//~^ WARNING unexpected `cfg` condition name
pub fn f() {}

#[cfg(test = "value")]
//~^ WARNING unexpected `cfg` condition value
pub fn f() {}

#[cfg(feature = "unk")]
//[feature]~^ WARNING unexpected `cfg` condition value
//[full]~^^ WARNING unexpected `cfg` condition value
pub fn feat() {}

#[cfg(feature = "std")]
pub fn feat() {}

#[cfg(windows)]
pub fn win() {}

#[cfg(unix)]
pub fn unix() {}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/empty-names.rs:6:7
--> $DIR/exhaustive-names.rs:8:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= 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`
= note: `#[warn(unexpected_cfgs)]` on by default

warning: 1 warning emitted
warning: unexpected `empty_names` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 2 warnings emitted

15 changes: 15 additions & 0 deletions tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/exhaustive-names.rs:8:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= 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`
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `exhaustive_names` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 2 warnings emitted

12 changes: 12 additions & 0 deletions tests/ui/check-cfg/exhaustive-names.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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

#[cfg(unknown_key = "value")]
//~^ WARNING unexpected `cfg` condition name
pub fn f() {}

fn main() {}
17 changes: 17 additions & 0 deletions tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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: unexpected `empty_cfg` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names

warning: 2 warnings emitted

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: unexpected `cfg` condition value: `value`
--> $DIR/empty-values.rs:6:7
--> $DIR/exhaustive-values.rs:9:7
|
LL | #[cfg(test = "value")]
| ^^^^----------
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/check-cfg/exhaustive-values.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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
// [empty_cfg]compile-flags: --check-cfg=cfg() -Z unstable-options
// [without_names]compile-flags: --check-cfg=cfg(any()) -Z unstable-options

#[cfg(test = "value")]
//~^ WARNING unexpected `cfg` condition value
pub fn f() {}

fn main() {}
13 changes: 13 additions & 0 deletions tests/ui/check-cfg/exhaustive-values.without_names.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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

Loading

0 comments on commit fc78d78

Please sign in to comment.