diff options
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/check-cfg/cargo-feature.none.stderr | 20 | ||||
| -rw-r--r-- | tests/ui/check-cfg/cargo-feature.rs | 9 | ||||
| -rw-r--r-- | tests/ui/check-cfg/cargo-feature.some.stderr | 7 | ||||
| -rw-r--r-- | tests/ui/check-cfg/concat-values.rs | 4 | ||||
| -rw-r--r-- | tests/ui/check-cfg/concat-values.stderr | 4 | ||||
| -rw-r--r-- | tests/ui/check-cfg/empty-values.rs | 14 | ||||
| -rw-r--r-- | tests/ui/check-cfg/empty-values.stderr | 23 |
7 files changed, 62 insertions, 19 deletions
diff --git a/tests/ui/check-cfg/cargo-feature.none.stderr b/tests/ui/check-cfg/cargo-feature.none.stderr index 9a308429484..aed4fd2a8c0 100644 --- a/tests/ui/check-cfg/cargo-feature.none.stderr +++ b/tests/ui/check-cfg/cargo-feature.none.stderr @@ -1,34 +1,36 @@ -warning: unexpected `cfg` condition name: `feature` - --> $DIR/cargo-feature.rs:13:7 +warning: unexpected `cfg` condition value: `serde` + --> $DIR/cargo-feature.rs:14:7 | LL | #[cfg(feature = "serde")] - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ help: remove the condition | - = help: consider defining some features in `Cargo.toml` + = note: no expected values for `feature` + = help: consider adding `serde` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default -warning: unexpected `cfg` condition name: `feature` +warning: unexpected `cfg` condition value: (none) --> $DIR/cargo-feature.rs:18:7 | LL | #[cfg(feature)] - | ^^^^^^^ + | ^^^^^^^ help: remove the condition | + = note: no expected values for `feature` = help: consider defining some features in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `tokio_unstable` - --> $DIR/cargo-feature.rs:23:7 + --> $DIR/cargo-feature.rs:22:7 | LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(tokio_unstable)");` to the top of a `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `CONFIG_NVME` - --> $DIR/cargo-feature.rs:27:7 + --> $DIR/cargo-feature.rs:26:7 | LL | #[cfg(CONFIG_NVME = "m")] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/cargo-feature.rs b/tests/ui/check-cfg/cargo-feature.rs index f2fd0fd6420..8542174d0c0 100644 --- a/tests/ui/check-cfg/cargo-feature.rs +++ b/tests/ui/check-cfg/cargo-feature.rs @@ -5,19 +5,18 @@ // check-pass // revisions: some none // rustc-env:CARGO=/usr/bin/cargo -// compile-flags: --check-cfg=cfg() -Z unstable-options +// compile-flags: -Z unstable-options +// [none]compile-flags: --check-cfg=cfg(feature,values()) // [some]compile-flags: --check-cfg=cfg(feature,values("bitcode")) // [some]compile-flags: --check-cfg=cfg(CONFIG_NVME,values("y")) // [none]error-pattern:Cargo.toml #[cfg(feature = "serde")] -//[none]~^ WARNING unexpected `cfg` condition name -//[some]~^^ WARNING unexpected `cfg` condition value +//~^ WARNING unexpected `cfg` condition value fn ser() {} #[cfg(feature)] -//[none]~^ WARNING unexpected `cfg` condition name -//[some]~^^ WARNING unexpected `cfg` condition value +//~^ WARNING unexpected `cfg` condition value fn feat() {} #[cfg(tokio_unstable)] diff --git a/tests/ui/check-cfg/cargo-feature.some.stderr b/tests/ui/check-cfg/cargo-feature.some.stderr index fc6951b5617..74d65e550bb 100644 --- a/tests/ui/check-cfg/cargo-feature.some.stderr +++ b/tests/ui/check-cfg/cargo-feature.some.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `serde` - --> $DIR/cargo-feature.rs:13:7 + --> $DIR/cargo-feature.rs:14:7 | LL | #[cfg(feature = "serde")] | ^^^^^^^^^^^^^^^^^ @@ -16,10 +16,11 @@ LL | #[cfg(feature)] | ^^^^^^^- help: specify a config value: `= "bitcode"` | = note: expected values for `feature` are: `bitcode` + = help: consider defining some features in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `tokio_unstable` - --> $DIR/cargo-feature.rs:23:7 + --> $DIR/cargo-feature.rs:22:7 | LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ @@ -29,7 +30,7 @@ LL | #[cfg(tokio_unstable)] = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `m` - --> $DIR/cargo-feature.rs:27:7 + --> $DIR/cargo-feature.rs:26:7 | LL | #[cfg(CONFIG_NVME = "m")] | ^^^^^^^^^^^^^^--- diff --git a/tests/ui/check-cfg/concat-values.rs b/tests/ui/check-cfg/concat-values.rs index 0f9178ce6a5..ad922f8c908 100644 --- a/tests/ui/check-cfg/concat-values.rs +++ b/tests/ui/check-cfg/concat-values.rs @@ -1,6 +1,7 @@ // check-pass // compile-flags: -Z unstable-options // compile-flags: --check-cfg=cfg(my_cfg,values("foo")) --check-cfg=cfg(my_cfg,values("bar")) +// compile-flags: --check-cfg=cfg(my_cfg,values()) #[cfg(my_cfg)] //~^ WARNING unexpected `cfg` condition value @@ -10,4 +11,7 @@ fn my_cfg() {} //~^ WARNING unexpected `cfg` condition value fn my_cfg() {} +#[cfg(any(my_cfg = "foo", my_cfg = "bar"))] +fn foo_and_bar() {} + fn main() {} diff --git a/tests/ui/check-cfg/concat-values.stderr b/tests/ui/check-cfg/concat-values.stderr index dec43f5bda3..6fe9f2baa09 100644 --- a/tests/ui/check-cfg/concat-values.stderr +++ b/tests/ui/check-cfg/concat-values.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: (none) - --> $DIR/concat-values.rs:5:7 + --> $DIR/concat-values.rs:6:7 | LL | #[cfg(my_cfg)] | ^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(my_cfg)] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `unk` - --> $DIR/concat-values.rs:9:7 + --> $DIR/concat-values.rs:10:7 | LL | #[cfg(my_cfg = "unk")] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/empty-values.rs b/tests/ui/check-cfg/empty-values.rs new file mode 100644 index 00000000000..7e6ba6ae84a --- /dev/null +++ b/tests/ui/check-cfg/empty-values.rs @@ -0,0 +1,14 @@ +// Check that we detect unexpected value when none are allowed +// +// check-pass +// compile-flags: --check-cfg=cfg(foo,values()) -Zunstable-options + +#[cfg(foo = "foo")] +//~^ WARNING unexpected `cfg` condition value +fn do_foo() {} + +#[cfg(foo)] +//~^ WARNING unexpected `cfg` condition value +fn do_foo() {} + +fn main() {} diff --git a/tests/ui/check-cfg/empty-values.stderr b/tests/ui/check-cfg/empty-values.stderr new file mode 100644 index 00000000000..e7b0b05d561 --- /dev/null +++ b/tests/ui/check-cfg/empty-values.stderr @@ -0,0 +1,23 @@ +warning: unexpected `cfg` condition value: `foo` + --> $DIR/empty-values.rs:6:7 + | +LL | #[cfg(foo = "foo")] + | ^^^^^^^^^^^ help: remove the condition + | + = note: no expected values for `foo` + = help: to expect this configuration use `--check-cfg=cfg(foo, values("foo"))` + = 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: (none) + --> $DIR/empty-values.rs:10:7 + | +LL | #[cfg(foo)] + | ^^^ help: remove the condition + | + = note: no expected values for `foo` + = help: to expect this configuration use `--check-cfg=cfg(foo)` + = 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 + |
