Skip to content

Commit f899d9f

Browse files
committed
[TRY] enumerate list of unavailable target features
1 parent 201d2a1 commit f899d9f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
name: Test
4141
runs-on: ${{ matrix.target.os }}
4242
strategy:
43+
fail-fast: true
4344
matrix:
4445
profile:
4546
- dev

crates/std_detect/src/detect/macros.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ macro_rules! detect_feature {
1414
};
1515
}
1616

17+
#[macro_export]
18+
macro_rules! detect_feature_direct {
19+
($feature:tt, $feature_lit:tt) => {
20+
$crate::detect_feature_direct!($feature, $feature_lit : $feature_lit)
21+
};
22+
($feature:tt, $feature_lit:tt : $($target_feature_lit:tt),*) => {
23+
$(cfg!(target_feature = $target_feature_lit) ||)*
24+
$crate::detect::check_for($crate::detect::Feature::$feature)
25+
};
26+
($feature:tt, $feature_lit:tt, without cfg check: true) => {
27+
$crate::detect::check_for($crate::detect::Feature::$feature)
28+
};
29+
}
30+
1731
#[allow(unused_macros, reason = "it's used in the features! macro below")]
1832
macro_rules! check_cfg_feature {
1933
($feature:tt, $feature_lit:tt) => {
@@ -140,6 +154,20 @@ macro_rules! features {
140154
)*
141155
}
142156

157+
#[test]
158+
#[cfg($cfg)]
159+
fn all_present() {
160+
let mut all_present = true;
161+
$(
162+
let present = $crate::detect_feature_direct!($feature, $feature_lit $(, without cfg check: $feature_cfg_check)? $(: $($target_feature_lit),*)?);
163+
all_present &= present;
164+
if !present {
165+
println!("{} not available", $feature_lit);
166+
}
167+
)*
168+
assert!(all_present, "not all features are available");
169+
}
170+
143171
/// Each variant denotes a position in a bitset for a particular feature.
144172
///
145173
/// PLEASE: do not use this, it is an implementation detail subject

0 commit comments

Comments
 (0)