11use 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,
34} ;
45use std:: collections:: HashMap ;
56use std:: env as std_env;
@@ -26,11 +27,7 @@ impl Channel {
2627}
2728
2829fn 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) )
3431}
3532
3633#[ derive( Default ) ]
@@ -48,11 +45,7 @@ impl ConfigFile {
4845 )
4946 } ) ?;
5047 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)
5649 } ) ?;
5750 let mut config = Self :: default ( ) ;
5851 for ( key, value) in toml. iter ( ) {
@@ -181,11 +174,7 @@ impl ConfigInfo {
181174 } ,
182175 "--use-backend" => match args. next ( ) {
183176 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 ( ) ) ,
189178 } ,
190179 "--no-default-features" => self . no_default_features = true ,
191180 _ => return Ok ( false ) ,
@@ -231,11 +220,7 @@ impl ConfigInfo {
231220 create_dir ( & output_dir) ?;
232221 }
233222 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)
239224 } ) ?;
240225
241226 let libgccjit_so_name = "libgccjit.so" ;
@@ -269,10 +254,7 @@ impl ConfigInfo {
269254 println ! ( "Downloaded libgccjit.so version {} successfully!" , commit) ;
270255 // We need to create a link named `libgccjit.so.0` because that's what the linker is
271256 // 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) ) ) ?;
276258 }
277259
278260 self . gcc_path = output_dir. display ( ) . to_string ( ) ;
@@ -292,10 +274,7 @@ impl ConfigInfo {
292274 Some ( config_file) => config_file. into ( ) ,
293275 None => self . compute_path ( "config.toml" ) ,
294276 } ;
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) ?;
299278
300279 if let Some ( true ) = download_gccjit {
301280 self . download_gccjit_if_needed ( ) ?;
@@ -304,10 +283,7 @@ impl ConfigInfo {
304283 self . gcc_path = match gcc_path {
305284 Some ( path) => path,
306285 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( ) , ) )
311287 }
312288 } ;
313289 Ok ( ( ) )
@@ -387,17 +363,15 @@ impl ConfigInfo {
387363 . join ( & format ! ( "librustc_codegen_gcc.{}" , self . dylib_ext) )
388364 . display ( )
389365 . 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 ( ) ;
394367 if let Some ( backend) = & self . backend {
395368 // This option is only used in the rust compiler testsuite. The sysroot is handled
396369 // by its build system directly so no need to set it ourselves.
397370 rustflags. push ( format ! ( "-Zcodegen-backend={}" , backend) ) ;
398371 } else {
399372 rustflags. extend_from_slice ( & [
400- "--sysroot" . to_string ( ) , self . sysroot_path . clone ( ) ,
373+ "--sysroot" . to_string ( ) ,
374+ self . sysroot_path . clone ( ) ,
401375 format ! ( "-Zcodegen-backend={}" , self . cg_backend_path) ,
402376 ] ) ;
403377 }
@@ -436,10 +410,8 @@ impl ConfigInfo {
436410 // display metadata load errors
437411 env. insert ( "RUSTC_LOG" . to_string ( ) , "warn" . to_string ( ) ) ;
438412
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, ) ) ;
443415 let ld_library_path = format ! (
444416 "{target}:{sysroot}:{gcc_path}" ,
445417 target = self . cargo_target_dir,
@@ -517,11 +489,7 @@ fn download_gccjit(
517489 & "--retry" ,
518490 & "3" ,
519491 & "-SRfL" ,
520- if with_progress_bar {
521- & "--progress-bar"
522- } else {
523- & "-s"
524- } ,
492+ if with_progress_bar { & "--progress-bar" } else { & "-s" } ,
525493 & url. as_str ( ) ,
526494 ] ,
527495 Some ( & output_dir) ,
0 commit comments