@@ -4,7 +4,7 @@ use std::{env, str};
4
4
// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we
5
5
// need to know all the possible cfgs that this script will set. If you need to set another cfg
6
6
// make sure to add it to this list as well.
7
- const ALLOWED_CFGS : & ' static [ & ' static str ] = & [
7
+ const ALLOWED_CFGS : & [ & str ] = & [
8
8
"emscripten_old_stat_abi" ,
9
9
"espidf_time32" ,
10
10
"freebsd10" ,
@@ -24,7 +24,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
24
24
] ;
25
25
26
26
// 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 ] ) ] = & [
28
28
(
29
29
"target_os" ,
30
30
& [
@@ -46,7 +46,6 @@ fn main() {
46
46
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
47
47
48
48
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 ( ) ;
50
49
let libc_ci = env:: var ( "LIBC_CI" ) . is_ok ( ) ;
51
50
let target_env = env:: var ( "CARGO_CFG_TARGET_ENV" ) . unwrap_or_default ( ) ;
52
51
let target_os = env:: var ( "CARGO_CFG_TARGET_OS" ) . unwrap_or_default ( ) ;
@@ -66,10 +65,8 @@ fn main() {
66
65
vers
67
66
} else if libc_ci {
68
67
which_freebsd ( ) . unwrap_or ( 12 )
69
- } else if rustc_dep_of_std {
70
- 12
71
68
} else {
72
- 12
69
+ 12 // regardless of CARGO_FEATURE_RUSTC_DEP_OF_STD env var
73
70
} ;
74
71
75
72
match which_freebsd {
@@ -163,12 +160,11 @@ fn rustc_version_cmd(is_clippy_driver: bool) -> Output {
163
160
164
161
let output = cmd. output ( ) . expect ( "Failed to get rustc version" ) ;
165
162
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
+ ) ;
172
168
173
169
output
174
170
}
@@ -195,9 +191,11 @@ fn rustc_minor_nightly() -> (u32, bool) {
195
191
196
192
let mut pieces = version. split ( '.' ) ;
197
193
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
+ ) ;
201
199
202
200
let minor = pieces. next ( ) ;
203
201
@@ -207,9 +205,9 @@ fn rustc_minor_nightly() -> (u32, bool) {
207
205
// since a nightly build should either come from CI
208
206
// or a git checkout
209
207
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
+ } ) ;
213
211
let minor = otry ! ( otry!( minor) . parse( ) . ok( ) ) ;
214
212
215
213
( minor, nightly)
@@ -260,8 +258,9 @@ fn emcc_version_code() -> Option<u64> {
260
258
}
261
259
262
260
fn 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
+ ) ;
266
265
println ! ( "cargo:rustc-cfg={cfg}" ) ;
267
266
}
0 commit comments