1
1
use crate :: utils:: {
2
- create_dir, create_symlink, get_os_name, run_command_with_output, rustc_version_info, split_args,
2
+ create_dir, create_symlink, get_os_name, run_command_with_output, rustc_version_info,
3
+ split_args,
3
4
} ;
4
5
use std:: collections:: HashMap ;
5
6
use std:: env as std_env;
@@ -26,11 +27,7 @@ impl Channel {
26
27
}
27
28
28
29
fn failed_config_parsing ( config_file : & Path , err : & str ) -> Result < ConfigFile , String > {
29
- Err ( format ! (
30
- "Failed to parse `{}`: {}" ,
31
- config_file. display( ) ,
32
- err
33
- ) )
30
+ Err ( format ! ( "Failed to parse `{}`: {}" , config_file. display( ) , err) )
34
31
}
35
32
36
33
#[ derive( Default ) ]
@@ -48,11 +45,7 @@ impl ConfigFile {
48
45
)
49
46
} ) ?;
50
47
let toml = Toml :: parse ( & content) . map_err ( |err| {
51
- format ! (
52
- "Error occurred around `{}`: {:?}" ,
53
- & content[ err. start..=err. end] ,
54
- err. kind
55
- )
48
+ format ! ( "Error occurred around `{}`: {:?}" , & content[ err. start..=err. end] , err. kind)
56
49
} ) ?;
57
50
let mut config = Self :: default ( ) ;
58
51
for ( key, value) in toml. iter ( ) {
@@ -181,11 +174,7 @@ impl ConfigInfo {
181
174
} ,
182
175
"--use-backend" => match args. next ( ) {
183
176
Some ( backend) if !backend. is_empty ( ) => self . backend = Some ( backend) ,
184
- _ => {
185
- return Err (
186
- "Expected an argument after `--use-backend`, found nothing" . into ( )
187
- )
188
- }
177
+ _ => return Err ( "Expected an argument after `--use-backend`, found nothing" . into ( ) ) ,
189
178
} ,
190
179
"--no-default-features" => self . no_default_features = true ,
191
180
_ => return Ok ( false ) ,
@@ -231,11 +220,7 @@ impl ConfigInfo {
231
220
create_dir ( & output_dir) ?;
232
221
}
233
222
let output_dir = output_dir. canonicalize ( ) . map_err ( |err| {
234
- format ! (
235
- "Failed to get absolute path of `{}`: {:?}" ,
236
- output_dir. display( ) ,
237
- err
238
- )
223
+ format ! ( "Failed to get absolute path of `{}`: {:?}" , output_dir. display( ) , err)
239
224
} ) ?;
240
225
241
226
let libgccjit_so_name = "libgccjit.so" ;
@@ -269,10 +254,7 @@ impl ConfigInfo {
269
254
println ! ( "Downloaded libgccjit.so version {} successfully!" , commit) ;
270
255
// We need to create a link named `libgccjit.so.0` because that's what the linker is
271
256
// looking for.
272
- create_symlink (
273
- & libgccjit_so,
274
- output_dir. join ( & format ! ( "{}.0" , libgccjit_so_name) ) ,
275
- ) ?;
257
+ create_symlink ( & libgccjit_so, output_dir. join ( & format ! ( "{}.0" , libgccjit_so_name) ) ) ?;
276
258
}
277
259
278
260
self . gcc_path = output_dir. display ( ) . to_string ( ) ;
@@ -292,10 +274,7 @@ impl ConfigInfo {
292
274
Some ( config_file) => config_file. into ( ) ,
293
275
None => self . compute_path ( "config.toml" ) ,
294
276
} ;
295
- let ConfigFile {
296
- gcc_path,
297
- download_gccjit,
298
- } = ConfigFile :: new ( & config_file) ?;
277
+ let ConfigFile { gcc_path, download_gccjit } = ConfigFile :: new ( & config_file) ?;
299
278
300
279
if let Some ( true ) = download_gccjit {
301
280
self . download_gccjit_if_needed ( ) ?;
@@ -304,10 +283,7 @@ impl ConfigInfo {
304
283
self . gcc_path = match gcc_path {
305
284
Some ( path) => path,
306
285
None => {
307
- return Err ( format ! (
308
- "missing `gcc-path` value from `{}`" ,
309
- config_file. display( ) ,
310
- ) )
286
+ return Err ( format ! ( "missing `gcc-path` value from `{}`" , config_file. display( ) , ) )
311
287
}
312
288
} ;
313
289
Ok ( ( ) )
@@ -387,17 +363,15 @@ impl ConfigInfo {
387
363
. join ( & format ! ( "librustc_codegen_gcc.{}" , self . dylib_ext) )
388
364
. display ( )
389
365
. to_string ( ) ;
390
- self . sysroot_path = current_dir
391
- . join ( "build_sysroot/sysroot" )
392
- . display ( )
393
- . to_string ( ) ;
366
+ self . sysroot_path = current_dir. join ( "build_sysroot/sysroot" ) . display ( ) . to_string ( ) ;
394
367
if let Some ( backend) = & self . backend {
395
368
// This option is only used in the rust compiler testsuite. The sysroot is handled
396
369
// by its build system directly so no need to set it ourselves.
397
370
rustflags. push ( format ! ( "-Zcodegen-backend={}" , backend) ) ;
398
371
} else {
399
372
rustflags. extend_from_slice ( & [
400
- "--sysroot" . to_string ( ) , self . sysroot_path . clone ( ) ,
373
+ "--sysroot" . to_string ( ) ,
374
+ self . sysroot_path . clone ( ) ,
401
375
format ! ( "-Zcodegen-backend={}" , self . cg_backend_path) ,
402
376
] ) ;
403
377
}
@@ -436,10 +410,8 @@ impl ConfigInfo {
436
410
// display metadata load errors
437
411
env. insert ( "RUSTC_LOG" . to_string ( ) , "warn" . to_string ( ) ) ;
438
412
439
- let sysroot = current_dir. join ( & format ! (
440
- "build_sysroot/sysroot/lib/rustlib/{}/lib" ,
441
- self . target_triple,
442
- ) ) ;
413
+ let sysroot = current_dir
414
+ . join ( & format ! ( "build_sysroot/sysroot/lib/rustlib/{}/lib" , self . target_triple, ) ) ;
443
415
let ld_library_path = format ! (
444
416
"{target}:{sysroot}:{gcc_path}" ,
445
417
target = self . cargo_target_dir,
@@ -517,11 +489,7 @@ fn download_gccjit(
517
489
& "--retry" ,
518
490
& "3" ,
519
491
& "-SRfL" ,
520
- if with_progress_bar {
521
- & "--progress-bar"
522
- } else {
523
- & "-s"
524
- } ,
492
+ if with_progress_bar { & "--progress-bar" } else { & "-s" } ,
525
493
& url. as_str ( ) ,
526
494
] ,
527
495
Some ( & output_dir) ,
0 commit comments