Silence unexpected_cfgs error about unknown cygwin target

Extract our own cfg value, to avoid noisy warnings like:

	warning: unexpected `cfg` condition value: `cygwin`
	  --> src/fallback.rs:78:23
	   |
	78 |             #[cfg(not(target_os = "cygwin"))]
	   |                       ^^^^^^^^^^^^^^^^^^^^
	   |

The cygwin target will be added to Rust 1.86, so we can get rid of this
after some time.
This commit is contained in:
Johannes Altmanninger
2025-04-01 17:22:11 +02:00
parent ec1c2473c2
commit 2719ae443b
6 changed files with 16 additions and 10 deletions

View File

@@ -90,6 +90,7 @@ fn detect_cfgs(target: &mut Target) {
),
("apple", &detect_apple),
("bsd", &detect_bsd),
("cygwin", &detect_cygwin),
("gettext", &have_gettext),
("small_main_stack", &has_small_stack),
// See if libc supports the thread-safe localeconv_l(3) alternative to localeconv(3).
@@ -128,6 +129,11 @@ fn detect_apple(_: &Target) -> Result<bool, Box<dyn Error>> {
Ok(cfg!(any(target_os = "ios", target_os = "macos")))
}
#[allow(unexpected_cfgs)]
fn detect_cygwin(_: &Target) -> Result<bool, Box<dyn Error>> {
Ok(cfg!(target_os = "cygwin"))
}
/// Detect if we're being compiled for a BSD-derived OS, allowing targeting code conditionally with
/// `#[cfg(bsd)]`.
///