From d2a383b4426e1b561b265ae80f5a21e72e90227c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 6 May 2024 20:56:30 -0700 Subject: [PATCH] Resolve unexpected_cfgs warning warning: unexpected `cfg` condition name: `remain_stable_testing` --> tests/unstable.rs:2:12 | 2 | #![cfg(not(remain_stable_testing))] | ^^^^^^^^^^^^^^^^^^^^^ | = 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(remain_stable_testing)");` 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 | 1 + build.rs | 7 +++++++ tests/unstable.rs | 1 + 3 files changed, 9 insertions(+) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index 1b3afaa..a0693c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ categories = ["development-tools", "no-std", "no-std::no-alloc"] description = "Compile-time checks that an enum, struct, or match is written in sorted order." documentation = "https://docs.rs/remain" edition = "2021" +exclude = ["build.rs"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/remain" rust-version = "1.56" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..113f8a0 --- /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(remain_stable_testing)"); +} diff --git a/tests/unstable.rs b/tests/unstable.rs index dd9fa80..b306de9 100644 --- a/tests/unstable.rs +++ b/tests/unstable.rs @@ -1,6 +1,7 @@ #![allow(dead_code)] #![cfg(not(remain_stable_testing))] #![feature(proc_macro_hygiene, stmt_expr_attributes)] +#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))] #![allow( clippy::derive_partial_eq_without_eq, clippy::extra_unused_type_parameters,