File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 35
35
// 1.57+.
36
36
37
37
use std:: env;
38
- use std:: process:: Command ;
38
+ use std:: ffi:: OsString ;
39
+ use std:: process:: { self , Command } ;
39
40
use std:: str;
40
41
use std:: u32;
41
42
@@ -89,7 +90,7 @@ struct RustcVersion {
89
90
}
90
91
91
92
fn rustc_version ( ) -> Option < RustcVersion > {
92
- let rustc = env :: var_os ( "RUSTC" ) ? ;
93
+ let rustc = cargo_env_var ( "RUSTC" ) ;
93
94
let output = Command :: new ( rustc) . arg ( "--version" ) . output ( ) . ok ( ) ?;
94
95
let version = str:: from_utf8 ( & output. stdout ) . ok ( ) ?;
95
96
let nightly = version. contains ( "nightly" ) || version. contains ( "dev" ) ;
@@ -131,3 +132,13 @@ fn feature_allowed(feature: &str) -> bool {
131
132
// No allow-features= flag, allowed by default.
132
133
true
133
134
}
135
+
136
+ fn cargo_env_var ( key : & str ) -> OsString {
137
+ env:: var_os ( key) . unwrap_or_else ( || {
138
+ eprintln ! (
139
+ "Environment variable ${} is not set during execution of build script" ,
140
+ key,
141
+ ) ;
142
+ process:: exit ( 1 ) ;
143
+ } )
144
+ }
You can’t perform that action at this time.
0 commit comments