File tree 3 files changed +27
-3
lines changed
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ auxv = "0.3.3"
31
31
cupid = " 0.6.0"
32
32
33
33
[features ]
34
- default = [ " std_detect_dlsym_getauxval" , " std_detect_file_io" ]
34
+ default = [ " std_detect_dlsym_getauxval" , " std_detect_file_io" , " std_detect_env_override " ]
35
35
std_detect_file_io = []
36
- std_detect_dlsym_getauxval = [ " libc" ]
36
+ std_detect_dlsym_getauxval = [ " libc" ]
37
+ std_detect_env_override = []
Original file line number Diff line number Diff line change @@ -69,6 +69,12 @@ macro_rules! features {
69
69
Feature :: _last => unreachable!( ) ,
70
70
}
71
71
}
72
+ pub fn from_str( s: & str ) -> Result <Feature , ( ) > {
73
+ match s {
74
+ $( $feature_lit => Ok ( Feature :: $feature) , ) *
75
+ _ => Err ( ( ) )
76
+ }
77
+ }
72
78
}
73
79
74
80
/// Each function performs run-time feature detection for a single
Original file line number Diff line number Diff line change @@ -97,10 +97,27 @@ cfg_if! {
97
97
}
98
98
}
99
99
100
+ fn detect_features ( ) -> cache:: Initializer {
101
+ let value = self :: os:: detect_features ( ) ;
102
+ if cfg ! ( feature = "std_detect_env_override" ) {
103
+ if let Ok ( disable) = std:: env:: var ( "RUST_STD_DETECT_UNSTABLE" ) {
104
+ let mut value = value;
105
+ for v in disable. split ( " " ) {
106
+ let _ = Feature :: from_str ( v) . map ( |v| value. unset ( v as u32 ) ) ;
107
+ }
108
+ value
109
+ } else {
110
+ value
111
+ }
112
+ } else {
113
+ value
114
+ }
115
+ }
116
+
100
117
/// Performs run-time feature detection.
101
118
#[ inline]
102
119
pub fn check_for ( x : Feature ) -> bool {
103
- cache:: test ( x as u32 , self :: os :: detect_features)
120
+ cache:: test ( x as u32 , detect_features)
104
121
}
105
122
106
123
/// Returns an `Iterator<Item=(&'static str, bool)>` where
You can’t perform that action at this time.
0 commit comments