Skip to content

Commit 670ff84

Browse files
committed
Handle unsupported fallback
1 parent 37712cc commit 670ff84

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

library/std/src/sys/env_consts.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
//! Constants associated with each target.
22
3-
// Keep entries sorted alphabetically.
3+
// Replaces the #[else] gate with #[cfg(not(any(…)))] of all the other gates.
4+
// This ensures that they must be mutually exclusive and do not have precedence
5+
// like cfg_if!.
6+
macro cfg_unordered(
7+
$(#[cfg($cfg:meta)] $os:item)*
8+
#[else] $fallback:item
9+
) {
10+
$(#[cfg($cfg)] $os)*
11+
#[cfg(not(any($($cfg),*)))] $fallback
12+
}
13+
14+
// Keep entries sorted alphabetically and mutually exclusive.
15+
16+
cfg_unordered! {
417

518
#[cfg(target_os = "aix")]
619
pub mod os {
@@ -375,3 +388,17 @@ pub mod os {
375388
pub const EXE_SUFFIX: &str = ".exe";
376389
pub const EXE_EXTENSION: &str = "exe";
377390
}
391+
392+
// The fallback when none of the other gates match.
393+
#[else]
394+
pub mod os {
395+
pub const FAMILY: &str = "";
396+
pub const OS: &str = "";
397+
pub const DLL_PREFIX: &str = "";
398+
pub const DLL_SUFFIX: &str = "";
399+
pub const DLL_EXTENSION: &str = "";
400+
pub const EXE_SUFFIX: &str = "";
401+
pub const EXE_EXTENSION: &str = "";
402+
}
403+
404+
}

0 commit comments

Comments
 (0)