File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ use std::process::Command;
33use std:: str;
44
55fn main ( ) {
6- let rustc_minor_ver =
7- rustc_minor_version ( ) . expect ( "Failed to get rustc version" ) ;
6+ let ( rustc_minor_ver, is_nightly ) =
7+ rustc_minor_nightly ( ) . expect ( "Failed to get rustc version" ) ;
88 let rustc_dep_of_std = env:: var ( "CARGO_FEATURE_RUSTC_DEP_OF_STD" ) . is_ok ( ) ;
99 let align_cargo_feature = env:: var ( "CARGO_FEATURE_ALIGN" ) . is_ok ( ) ;
1010 let const_extern_fn_cargo_feature = env:: var ( "CARGO_FEATURE_CONST_EXTERN_FN" ) . is_ok ( ) ;
@@ -75,11 +75,14 @@ fn main() {
7575 }
7676
7777 if const_extern_fn_cargo_feature {
78+ if !is_nightly || rustc_minor_ver < 40 {
79+ panic ! ( "const-extern-fn requires a nightly compiler >= 1.40" )
80+ }
7881 println ! ( "cargo:rustc-cfg=libc_const_extern_fn" ) ;
7982 }
8083}
8184
82- fn rustc_minor_version ( ) -> Option < u32 > {
85+ fn rustc_minor_nightly ( ) -> Option < ( u32 , bool ) > {
8386 macro_rules! otry {
8487 ( $e: expr) => {
8588 match $e {
@@ -98,7 +101,12 @@ fn rustc_minor_version() -> Option<u32> {
98101 return None ;
99102 }
100103
101- otry ! ( pieces. next( ) ) . parse ( ) . ok ( )
104+ let minor = pieces. next ( ) ;
105+ let nightly_raw = otry ! ( otry!( pieces. next( ) ) . split( '-' ) . nth( 1 ) ) ;
106+ let nightly = nightly_raw. starts_with ( "dev" ) || nightly_raw. starts_with ( "nightly" ) ;
107+ let minor = otry ! ( otry!( minor) . parse( ) . ok( ) ) ;
108+
109+ Some ( ( minor, nightly) )
102110}
103111
104112fn which_freebsd ( ) -> Option < i32 > {
You can’t perform that action at this time.
0 commit comments