From 6132d8b4b1d9d81daa7774ec481e9eb8e295e94e Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 6 May 2024 18:48:26 -0700 Subject: [PATCH] Resolve unexpected_cfgs warning warning: unexpected `cfg` condition name: `exhaustive` --> tests/exhaustive.rs:1:8 | 1 | #![cfg(exhaustive)] | ^^^^^^^^^^ | = 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 for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default --- Cargo.toml | 2 +- build.rs | 7 +++++++ src/lib.rs | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index aab4449..8ffa282 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ categories = ["value-formatting", "no-std", "no-std::no-alloc"] description = "Fast floating point to string conversion" documentation = "https://docs.rs/ryu" edition = "2018" -exclude = ["performance.png", "chart/**"] +exclude = ["build.rs", "performance.png", "chart/**"] keywords = ["float"] license = "Apache-2.0 OR BSL-1.0" repository = "https://github.com/dtolnay/ryu" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..ecd2acf --- /dev/null +++ b/build.rs @@ -0,0 +1,7 @@ +fn main() { + // Warning: build.rs is not published to crates.io. + + println!("cargo:rustc-cfg=check_cfg"); + println!("cargo:rustc-check-cfg=cfg(check_cfg)"); + println!("cargo:rustc-check-cfg=cfg(exhaustive)"); +} diff --git a/src/lib.rs b/src/lib.rs index 0ec6038..fb1d071 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,6 +82,7 @@ #![no_std] #![doc(html_root_url = "https://docs.rs/ryu/1.0.17")] +#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))] #![allow( clippy::cast_lossless, clippy::cast_possible_truncation,