File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 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"
3131cupid = " 0.6.0"
3232
3333[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 " ]
3535std_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 {
6969 Feature :: _last => unreachable!( ) ,
7070 }
7171 }
72+ pub fn from_str( s: & str ) -> Result <Feature , ( ) > {
73+ match s {
74+ $( $feature_lit => Ok ( Feature :: $feature) , ) *
75+ _ => Err ( ( ) )
76+ }
77+ }
7278 }
7379
7480 /// 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! {
9797 }
9898}
9999
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+
100117/// Performs run-time feature detection.
101118#[ inline]
102119pub fn check_for ( x : Feature ) -> bool {
103- cache:: test ( x as u32 , self :: os :: detect_features)
120+ cache:: test ( x as u32 , detect_features)
104121}
105122
106123/// Returns an `Iterator<Item=(&'static str, bool)>` where
You can’t perform that action at this time.
0 commit comments