@@ -160,12 +160,11 @@ fn rustc_version_cmd(is_clippy_driver: bool) -> Output {
160
160
161
161
let output = cmd. output ( ) . expect ( "Failed to get rustc version" ) ;
162
162
163
- if !output. status . success ( ) {
164
- panic ! (
165
- "failed to run rustc: {}" ,
166
- String :: from_utf8_lossy( output. stderr. as_slice( ) )
167
- ) ;
168
- }
163
+ assert ! (
164
+ output. status. success( ) ,
165
+ "failed to run rustc: {}" ,
166
+ String :: from_utf8_lossy( output. stderr. as_slice( ) )
167
+ ) ;
169
168
170
169
output
171
170
}
@@ -192,9 +191,11 @@ fn rustc_minor_nightly() -> (u32, bool) {
192
191
193
192
let mut pieces = version. split ( '.' ) ;
194
193
195
- if pieces. next ( ) != Some ( "rustc 1" ) {
196
- panic ! ( "Failed to get rustc version" ) ;
197
- }
194
+ assert_eq ! (
195
+ pieces. next( ) ,
196
+ Some ( "rustc 1" ) ,
197
+ "Failed to get rustc version"
198
+ ) ;
198
199
199
200
let minor = pieces. next ( ) ;
200
201
@@ -204,9 +205,9 @@ fn rustc_minor_nightly() -> (u32, bool) {
204
205
// since a nightly build should either come from CI
205
206
// or a git checkout
206
207
let nightly_raw = otry ! ( pieces. next( ) ) . split ( '-' ) . nth ( 1 ) ;
207
- let nightly = nightly_raw
208
- . map ( | raw| raw . starts_with ( "dev" ) || raw. starts_with ( "nightly" ) )
209
- . unwrap_or ( false ) ;
208
+ let nightly = nightly_raw. map_or ( false , |raw| {
209
+ raw. starts_with ( "dev" ) || raw. starts_with ( "nightly" )
210
+ } ) ;
210
211
let minor = otry ! ( otry!( minor) . parse( ) . ok( ) ) ;
211
212
212
213
( minor, nightly)
@@ -251,8 +252,9 @@ fn emcc_version_code() -> Option<u64> {
251
252
}
252
253
253
254
fn set_cfg ( cfg : & str ) {
254
- if !ALLOWED_CFGS . contains ( & cfg) {
255
- panic ! ( "trying to set cfg {cfg}, but it is not in ALLOWED_CFGS" ) ;
256
- }
255
+ assert ! (
256
+ ALLOWED_CFGS . contains( & cfg) ,
257
+ "trying to set cfg {cfg}, but it is not in ALLOWED_CFGS" ,
258
+ ) ;
257
259
println ! ( "cargo:rustc-cfg={cfg}" ) ;
258
260
}
0 commit comments