Skip to content

Commit 220ca0c

Browse files
committed
Resolve unexpected_cfgs warning
warning: unexpected `cfg` condition name: `serde_build_from_git` --> serde_derive_internals/lib.rs:45:12 | 45 | #[cfg_attr(serde_build_from_git, path = "../serde_derive/src/internals/mod.rs")] | ^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `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`, `ub_checks`, `unix`, `windows` = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(serde_build_from_git)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `serde_build_from_git` --> serde_derive_internals/lib.rs:46:16 | 46 | #[cfg_attr(not(serde_build_from_git), path = "src/mod.rs")] | ^^^^^^^^^^^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(serde_build_from_git)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `deserialize_in_place` --> serde_derive_internals/src/attr.rs:276:11 | 276 | #[cfg(feature = "deserialize_in_place")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the condition | = note: no expected values for `feature` = help: consider adding `deserialize_in_place` as a feature in `Cargo.toml` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive_internals/src/attr.rs:1797:31 | 1797 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive_internals/src/receiver.rs:110:35 | 110 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive_internals/src/receiver.rs:181:47 | 181 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive_internals/src/receiver.rs:210:35 | 210 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive_internals/src/receiver.rs:231:43 | 231 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive/src/lib.rs:62:23 | 62 | #![cfg_attr(all(test, exhaustive), feature(non_exhaustive_omitted_patterns_lint))] | ^^^^^^^^^^ | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `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`, `ub_checks`, `unix`, `windows` = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive/src/internals/attr.rs:1797:31 | 1797 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive/src/internals/receiver.rs:110:35 | 110 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive/src/internals/receiver.rs:181:47 | 181 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive/src/internals/receiver.rs:210:35 | 210 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive/src/internals/receiver.rs:231:43 | 231 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive/src/bound.rs:147:39 | 147 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive/src/bound.rs:199:51 | 199 | ... #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `exhaustive` --> serde_derive/src/bound.rs:228:39 | 228 | #![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] | ^^^^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(exhaustive)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `systemtime_checked_add` --> test_suite/tests/test_de_error.rs:1527:7 | 1527 | #[cfg(systemtime_checked_add)] | ^^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `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`, `ub_checks`, `unix`, `windows` = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(systemtime_checked_add)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default
1 parent 20306f4 commit 220ca0c

File tree

7 files changed

+33
-1
lines changed

7 files changed

+33
-1
lines changed

serde/build.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ fn main() {
1313
None => return,
1414
};
1515

16+
if minor >= 77 {
17+
println!("cargo:rustc-check-cfg=cfg(doc_cfg)");
18+
println!("cargo:rustc-check-cfg=cfg(no_core_cstr)");
19+
println!("cargo:rustc-check-cfg=cfg(no_core_num_saturating)");
20+
println!("cargo:rustc-check-cfg=cfg(no_core_try_from)");
21+
println!("cargo:rustc-check-cfg=cfg(no_float_copysign)");
22+
println!("cargo:rustc-check-cfg=cfg(no_num_nonzero_signed)");
23+
println!("cargo:rustc-check-cfg=cfg(no_relaxed_trait_bounds)");
24+
println!("cargo:rustc-check-cfg=cfg(no_serde_derive)");
25+
println!("cargo:rustc-check-cfg=cfg(no_std_atomic)");
26+
println!("cargo:rustc-check-cfg=cfg(no_std_atomic64)");
27+
println!("cargo:rustc-check-cfg=cfg(no_systemtime_checked_add)");
28+
println!("cargo:rustc-check-cfg=cfg(no_target_has_atomic)");
29+
}
30+
1631
let target = env::var("TARGET").unwrap();
1732
let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten";
1833

serde_derive/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ categories = ["no-std", "no-std::no-alloc"]
66
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
77
documentation = "https://serde.rs/derive.html"
88
edition = "2015"
9+
exclude = ["build.rs"]
910
homepage = "https://serde.rs"
1011
keywords = ["serde", "serialization", "no_std", "derive"]
1112
license = "MIT OR Apache-2.0"

serde_derive/build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
// Warning: build.rs is not published to crates.io.
3+
4+
println!("cargo:rustc-cfg=check_cfg");
5+
println!("cargo:rustc-check-cfg=cfg(check_cfg)");
6+
println!("cargo:rustc-check-cfg=cfg(exhaustive)");
7+
}

serde_derive/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
1515
1616
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.200")]
17+
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
1718
// Ignored clippy lints
1819
#![allow(
1920
// clippy false positive: https://github.com/rust-lang/rust-clippy/issues/7054

serde_derive_internals/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
use std::path::Path;
22

33
fn main() {
4+
// Warning: build.rs is not published to crates.io.
5+
46
println!("cargo:rerun-if-changed=build.rs");
57
println!("cargo:rerun-if-changed=src/mod.rs");
68

9+
println!("cargo:rustc-cfg=check_cfg");
10+
println!("cargo:rustc-check-cfg=cfg(check_cfg)");
11+
println!("cargo:rustc-check-cfg=cfg(exhaustive)");
12+
println!("cargo:rustc-check-cfg=cfg(serde_build_from_git)");
13+
println!("cargo:rustc-check-cfg=cfg(feature, values(\"deserialize_in_place\"))");
14+
715
// Sometimes on Windows the git checkout does not correctly wire up the
816
// symlink from serde_derive_internals/src to serde_derive/src/internals.
917
// When this happens we'll just build based on relative paths within the git

serde_derive_internals/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![doc(html_root_url = "https://docs.rs/serde_derive_internals/0.29.0")]
2+
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
23
// Ignored clippy lints
34
#![allow(
45
clippy::cognitive_complexity,

test_suite/tests/test_de_error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,6 @@ fn test_systemtime_overflow_struct() {
15241524
);
15251525
}
15261526

1527-
#[cfg(not(no_systemtime_checked_add))]
15281527
#[test]
15291528
fn test_systemtime_overflow() {
15301529
assert_de_tokens_error::<SystemTime>(

0 commit comments

Comments
 (0)