@@ -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" ) ]
1832macro_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