@@ -28,6 +28,20 @@ macro_rules! check_cfg_feature {
28
28
} ;
29
29
}
30
30
31
+ #[ allow( unused_macros, reason = "it's used in the features! macro below" ) ]
32
+ macro_rules! detect_feature_direct {
33
+ ( $feature: tt, $feature_lit: tt) => {
34
+ detect_feature_direct!( $feature, $feature_lit : $feature_lit)
35
+ } ;
36
+ ( $feature: tt, $feature_lit: tt : $( $target_feature_lit: tt) ,* ) => {
37
+ $( cfg!( target_feature = $target_feature_lit) ||) *
38
+ $crate:: detect:: check_for( $crate:: detect:: Feature :: $feature)
39
+ } ;
40
+ ( $feature: tt, $feature_lit: tt, without cfg check: true ) => {
41
+ $crate:: detect:: check_for( $crate:: detect:: Feature :: $feature)
42
+ } ;
43
+ }
44
+
31
45
#[ allow( unused) ]
32
46
macro_rules! features {
33
47
(
@@ -40,6 +54,7 @@ macro_rules! features {
40
54
$( @FEATURE : #[ $stability_attr: meta] $feature: ident: $feature_lit: tt;
41
55
$( without cfg check: $feature_cfg_check: tt; ) ?
42
56
$( implied by target_features: [ $( $target_feature_lit: tt) ,* ] ; ) ?
57
+ $( ignore in tests: $ignore_in_tests: tt; ) ?
43
58
$( #[ $feature_comment: meta] ) * ) *
44
59
) => {
45
60
#[ macro_export]
@@ -141,14 +156,19 @@ macro_rules! features {
141
156
}
142
157
143
158
#[ test]
144
- #[ cfg( $cfg) ]
145
- #[ cfg( stdarch_test_everything) ]
159
+ #[ cfg( all( stdarch_test_everything, $cfg) ) ]
146
160
fn everything_present( ) {
161
+ #[ allow( unused_mut) ]
162
+ let mut any_failed = false ;
147
163
$(
148
- assert!( $crate:: detect:: check_for( $crate:: detect:: Feature :: $feature) ,
149
- concat!( "Feature " , $feature_lit, " is not present on this target" )
150
- ) ;
164
+ if $( !$ignore_in_tests &&) ? !detect_feature_direct!( $feature, $feature_lit $( , without cfg check: $feature_cfg_check) ? $( : $( $target_feature_lit) ,* ) ?) {
165
+ any_failed = true ;
166
+ eprintln!( "`{}` not available" , $feature_lit) ;
167
+ }
151
168
) *
169
+ if any_failed {
170
+ panic!( "Some features are not present on this `TEST_EVERYTHING` target" ) ;
171
+ }
152
172
}
153
173
154
174
/// Each variant denotes a position in a bitset for a particular feature.
0 commit comments