@@ -4,7 +4,7 @@ use std::{env, str};
44// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we
55// need to know all the possible cfgs that this script will set. If you need to set another cfg
66// make sure to add it to this list as well.
7- const ALLOWED_CFGS : & ' static [ & ' static str ] = & [
7+ const ALLOWED_CFGS : & [ & str ] = & [
88 "emscripten_old_stat_abi" ,
99 "espidf_time32" ,
1010 "freebsd10" ,
@@ -24,7 +24,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
2424] ;
2525
2626// Extra values to allow for check-cfg.
27- const CHECK_CFG_EXTRA : & ' static [ ( & ' static str , & ' static [ & ' static str ] ) ] = & [
27+ const CHECK_CFG_EXTRA : & [ ( & str , & [ & str ] ) ] = & [
2828 (
2929 "target_os" ,
3030 & [
@@ -46,7 +46,6 @@ fn main() {
4646 println ! ( "cargo:rerun-if-changed=build.rs" ) ;
4747
4848 let ( rustc_minor_ver, _is_nightly) = rustc_minor_nightly ( ) ;
49- let rustc_dep_of_std = env:: var ( "CARGO_FEATURE_RUSTC_DEP_OF_STD" ) . is_ok ( ) ;
5049 let libc_ci = env:: var ( "LIBC_CI" ) . is_ok ( ) ;
5150 let target_env = env:: var ( "CARGO_CFG_TARGET_ENV" ) . unwrap_or_default ( ) ;
5251 let target_os = env:: var ( "CARGO_CFG_TARGET_OS" ) . unwrap_or_default ( ) ;
@@ -66,10 +65,8 @@ fn main() {
6665 vers
6766 } else if libc_ci {
6867 which_freebsd ( ) . unwrap_or ( 12 )
69- } else if rustc_dep_of_std {
70- 12
7168 } else {
72- 12
69+ 12 // regardless of CARGO_FEATURE_RUSTC_DEP_OF_STD env var
7370 } ;
7471
7572 match which_freebsd {
@@ -163,12 +160,11 @@ fn rustc_version_cmd(is_clippy_driver: bool) -> Output {
163160
164161 let output = cmd. output ( ) . expect ( "Failed to get rustc version" ) ;
165162
166- if !output. status . success ( ) {
167- panic ! (
168- "failed to run rustc: {}" ,
169- String :: from_utf8_lossy( output. stderr. as_slice( ) )
170- ) ;
171- }
163+ assert ! (
164+ output. status. success( ) ,
165+ "failed to run rustc: {}" ,
166+ String :: from_utf8_lossy( output. stderr. as_slice( ) )
167+ ) ;
172168
173169 output
174170}
@@ -195,9 +191,11 @@ fn rustc_minor_nightly() -> (u32, bool) {
195191
196192 let mut pieces = version. split ( '.' ) ;
197193
198- if pieces. next ( ) != Some ( "rustc 1" ) {
199- panic ! ( "Failed to get rustc version" ) ;
200- }
194+ assert_eq ! (
195+ pieces. next( ) ,
196+ Some ( "rustc 1" ) ,
197+ "Failed to get rustc version"
198+ ) ;
201199
202200 let minor = pieces. next ( ) ;
203201
@@ -207,9 +205,9 @@ fn rustc_minor_nightly() -> (u32, bool) {
207205 // since a nightly build should either come from CI
208206 // or a git checkout
209207 let nightly_raw = otry ! ( pieces. next( ) ) . split ( '-' ) . nth ( 1 ) ;
210- let nightly = nightly_raw
211- . map ( | raw| raw . starts_with ( "dev" ) || raw. starts_with ( "nightly" ) )
212- . unwrap_or ( false ) ;
208+ let nightly = nightly_raw. map_or ( false , |raw| {
209+ raw. starts_with ( "dev" ) || raw. starts_with ( "nightly" )
210+ } ) ;
213211 let minor = otry ! ( otry!( minor) . parse( ) . ok( ) ) ;
214212
215213 ( minor, nightly)
@@ -260,8 +258,9 @@ fn emcc_version_code() -> Option<u64> {
260258}
261259
262260fn set_cfg ( cfg : & str ) {
263- if !ALLOWED_CFGS . contains ( & cfg) {
264- panic ! ( "trying to set cfg {cfg}, but it is not in ALLOWED_CFGS" ) ;
265- }
261+ assert ! (
262+ ALLOWED_CFGS . contains( & cfg) ,
263+ "trying to set cfg {cfg}, but it is not in ALLOWED_CFGS" ,
264+ ) ;
266265 println ! ( "cargo:rustc-cfg={cfg}" ) ;
267266}
0 commit comments