File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 3535// 1.57+.
3636
3737use std:: env;
38- use std:: process:: Command ;
38+ use std:: ffi:: OsString ;
39+ use std:: process:: { self , Command } ;
3940use std:: str;
4041use std:: u32;
4142
@@ -89,7 +90,7 @@ struct RustcVersion {
8990}
9091
9192fn rustc_version ( ) -> Option < RustcVersion > {
92- let rustc = env :: var_os ( "RUSTC" ) ? ;
93+ let rustc = cargo_env_var ( "RUSTC" ) ;
9394 let output = Command :: new ( rustc) . arg ( "--version" ) . output ( ) . ok ( ) ?;
9495 let version = str:: from_utf8 ( & output. stdout ) . ok ( ) ?;
9596 let nightly = version. contains ( "nightly" ) || version. contains ( "dev" ) ;
@@ -131,3 +132,13 @@ fn feature_allowed(feature: &str) -> bool {
131132 // No allow-features= flag, allowed by default.
132133 true
133134}
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