diff options
| author | Thalia Archibald <thalia@archibald.dev> | 2025-04-15 06:42:39 -0700 |
|---|---|---|
| committer | Thalia Archibald <thalia@archibald.dev> | 2025-04-18 19:49:23 -0700 |
| commit | 670ff84d1c70146a2556b41650d3e417143c6c60 (patch) | |
| tree | f0b7ab173ec3572bd84b2500215324bdc82f39bb | |
| parent | 37712cc01604633fec6aac9bc720210207fa4b54 (diff) | |
| download | rust-670ff84d1c70146a2556b41650d3e417143c6c60.tar.gz rust-670ff84d1c70146a2556b41650d3e417143c6c60.zip | |
Handle unsupported fallback
| -rw-r--r-- | library/std/src/sys/env_consts.rs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/library/std/src/sys/env_consts.rs b/library/std/src/sys/env_consts.rs index f439aa5a905..018d7954db2 100644 --- a/library/std/src/sys/env_consts.rs +++ b/library/std/src/sys/env_consts.rs @@ -1,6 +1,19 @@ //! Constants associated with each target. -// Keep entries sorted alphabetically. +// Replaces the #[else] gate with #[cfg(not(any(…)))] of all the other gates. +// This ensures that they must be mutually exclusive and do not have precedence +// like cfg_if!. +macro cfg_unordered( + $(#[cfg($cfg:meta)] $os:item)* + #[else] $fallback:item +) { + $(#[cfg($cfg)] $os)* + #[cfg(not(any($($cfg),*)))] $fallback +} + +// Keep entries sorted alphabetically and mutually exclusive. + +cfg_unordered! { #[cfg(target_os = "aix")] pub mod os { @@ -375,3 +388,17 @@ pub mod os { pub const EXE_SUFFIX: &str = ".exe"; pub const EXE_EXTENSION: &str = "exe"; } + +// The fallback when none of the other gates match. +#[else] +pub mod os { + pub const FAMILY: &str = ""; + pub const OS: &str = ""; + pub const DLL_PREFIX: &str = ""; + pub const DLL_SUFFIX: &str = ""; + pub const DLL_EXTENSION: &str = ""; + pub const EXE_SUFFIX: &str = ""; + pub const EXE_EXTENSION: &str = ""; +} + +} |
