Skip to content

Commit 0648263

Browse files
committed
Handle unsupported fallback
1 parent 37712cc commit 0648263

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

Diff for: library/std/src/sys/env_consts.rs

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
//! Constants associated with each target.
22
3-
// Keep entries sorted alphabetically.
3+
// Collect all #[cfg(…)] gates, so that the #[else] fallback entry is
4+
// #[cfg(not(any(…)))] of all of them. This ensures that they must be mutually
5+
// exclusive and do not have precedence like cfg_if!.
6+
macro_rules! cfg_unordered {
7+
([$($cfgs:meta,)*] #[cfg($cfg:meta)] $os:item $($rest:tt)*) => {
8+
#[cfg($cfg)] $os
9+
cfg_unordered!([$($cfgs,)* $cfg,] $($rest)*);
10+
};
11+
([$($cfgs:meta,)*] #[else] $last:item) => {
12+
#[cfg(not(any($($cfgs),*)))] $last
13+
};
14+
}
15+
16+
// Keep entries sorted alphabetically and mutually exclusive.
17+
18+
cfg_unordered! { []
419

520
#[cfg(target_os = "aix")]
621
pub mod os {
@@ -375,3 +390,17 @@ pub mod os {
375390
pub const EXE_SUFFIX: &str = ".exe";
376391
pub const EXE_EXTENSION: &str = "exe";
377392
}
393+
394+
// Fallback when unsupported:
395+
#[else]
396+
pub mod os {
397+
pub const FAMILY: &str = "";
398+
pub const OS: &str = "";
399+
pub const DLL_PREFIX: &str = "";
400+
pub const DLL_SUFFIX: &str = "";
401+
pub const DLL_EXTENSION: &str = "";
402+
pub const EXE_SUFFIX: &str = "";
403+
pub const EXE_EXTENSION: &str = "";
404+
}
405+
406+
}

0 commit comments

Comments
 (0)