Skip to content

Commit 621e241

Browse files
committed
Add check-cfg test for Cargo feature without value
1 parent 29abb90 commit 621e241

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

tests/ui/check-cfg/cargo-feature.none.stderr

+12-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ LL | #[cfg(feature = "serde")]
88
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
99
= note: `#[warn(unexpected_cfgs)]` on by default
1010

11-
warning: unexpected `cfg` condition name: `tokio_unstable`
11+
warning: unexpected `cfg` condition name: `feature`
1212
--> $DIR/cargo-feature.rs:18:7
1313
|
14+
LL | #[cfg(feature)]
15+
| ^^^^^^^
16+
|
17+
= help: consider defining some features in `Cargo.toml`
18+
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
19+
20+
warning: unexpected `cfg` condition name: `tokio_unstable`
21+
--> $DIR/cargo-feature.rs:23:7
22+
|
1423
LL | #[cfg(tokio_unstable)]
1524
| ^^^^^^^^^^^^^^
1625
|
@@ -19,13 +28,13 @@ LL | #[cfg(tokio_unstable)]
1928
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
2029

2130
warning: unexpected `cfg` condition name: `CONFIG_NVME`
22-
--> $DIR/cargo-feature.rs:22:7
31+
--> $DIR/cargo-feature.rs:27:7
2332
|
2433
LL | #[cfg(CONFIG_NVME = "m")]
2534
| ^^^^^^^^^^^^^^^^^
2635
|
2736
= help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of a `build.rs`
2837
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
2938

30-
warning: 3 warnings emitted
39+
warning: 4 warnings emitted
3140

tests/ui/check-cfg/cargo-feature.rs

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
//[some]~^^ WARNING unexpected `cfg` condition value
1616
fn ser() {}
1717

18+
#[cfg(feature)]
19+
//[none]~^ WARNING unexpected `cfg` condition name
20+
//[some]~^^ WARNING unexpected `cfg` condition value
21+
fn feat() {}
22+
1823
#[cfg(tokio_unstable)]
1924
//~^ WARNING unexpected `cfg` condition name
2025
fn tokio() {}

tests/ui/check-cfg/cargo-feature.some.stderr

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ LL | #[cfg(feature = "serde")]
99
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

12-
warning: unexpected `cfg` condition name: `tokio_unstable`
12+
warning: unexpected `cfg` condition value: (none)
1313
--> $DIR/cargo-feature.rs:18:7
1414
|
15+
LL | #[cfg(feature)]
16+
| ^^^^^^^
17+
|
18+
= note: expected values for `feature` are: `bitcode`
19+
= help: consider defining `feature` as feature in `Cargo.toml`
20+
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
21+
22+
warning: unexpected `cfg` condition name: `tokio_unstable`
23+
--> $DIR/cargo-feature.rs:23:7
24+
|
1525
LL | #[cfg(tokio_unstable)]
1626
| ^^^^^^^^^^^^^^
1727
|
@@ -20,7 +30,7 @@ LL | #[cfg(tokio_unstable)]
2030
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
2131

2232
warning: unexpected `cfg` condition value: `m`
23-
--> $DIR/cargo-feature.rs:22:7
33+
--> $DIR/cargo-feature.rs:27:7
2434
|
2535
LL | #[cfg(CONFIG_NVME = "m")]
2636
| ^^^^^^^^^^^^^^---
@@ -31,5 +41,5 @@ LL | #[cfg(CONFIG_NVME = "m")]
3141
= help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of a `build.rs`
3242
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration
3343

34-
warning: 3 warnings emitted
44+
warning: 4 warnings emitted
3545

0 commit comments

Comments
 (0)