@@ -392,27 +392,67 @@ impl Config {
392
392
)
393
393
) ]
394
394
pub ( crate ) fn parse_inner (
395
- mut flags : Flags ,
395
+ flags : Flags ,
396
396
get_toml : impl Fn ( & Path ) -> Result < TomlConfig , toml:: de:: Error > ,
397
397
) -> Config {
398
+ let Flags {
399
+ cmd : flags_cmd,
400
+ verbose : flags_verbose,
401
+ incremental : flags_incremental,
402
+ config : flags_config,
403
+ build_dir : flags_build_dir,
404
+ build : flags_build,
405
+ host : flags_host,
406
+ target : flags_target,
407
+ exclude : flags_exclude,
408
+ skip : flags_skip,
409
+ include_default_paths : flags_include_default_paths,
410
+ rustc_error_format : flags_rustc_error_format,
411
+ on_fail : flags_on_fail,
412
+ dry_run : flags_dry_run,
413
+ dump_bootstrap_shims : flags_dump_bootstrap_shims,
414
+ stage : flags_stage,
415
+ keep_stage : flags_keep_stage,
416
+ keep_stage_std : flags_keep_stage_std,
417
+ src : flags_src,
418
+ jobs : flags_jobs,
419
+ warnings : flags_warnings,
420
+ error_format : flags_error_format,
421
+ json_output : flags_json_output,
422
+ color : flags_color,
423
+ bypass_bootstrap_lock : flags_bypass_bootstrap_lock,
424
+ rust_profile_generate : flags_rust_profile_generate,
425
+ rust_profile_use : flags_rust_profile_use,
426
+ llvm_profile_use : flags_llvm_profile_use,
427
+ llvm_profile_generate : flags_llvm_profile_generate,
428
+ enable_bolt_settings : flags_enable_bolt_settings,
429
+ skip_stage0_validation : flags_skip_stage0_validation,
430
+ reproducible_artifact : flags_reproducible_artifact,
431
+ paths : mut flags_paths,
432
+ set : flags_set,
433
+ free_args : mut flags_free_args,
434
+ ci : flags_ci,
435
+ skip_std_check_if_no_download_rustc : flags_skip_std_check_if_no_download_rustc,
436
+ } = flags;
437
+
398
438
let mut config = Config :: default_opts ( ) ;
399
439
let mut exec_ctx = ExecutionContext :: new ( ) ;
400
- exec_ctx. set_verbose ( flags . verbose ) ;
401
- exec_ctx. set_fail_fast ( flags . cmd . fail_fast ( ) ) ;
440
+ exec_ctx. set_verbose ( flags_verbose ) ;
441
+ exec_ctx. set_fail_fast ( flags_cmd . fail_fast ( ) ) ;
402
442
403
443
config. exec_ctx = exec_ctx;
404
444
405
445
// Set flags.
406
- config. paths = std:: mem:: take ( & mut flags . paths ) ;
446
+ config. paths = std:: mem:: take ( & mut flags_paths ) ;
407
447
408
448
#[ cfg( feature = "tracing" ) ]
409
449
span ! (
410
450
target: "CONFIG_HANDLING" ,
411
451
tracing:: Level :: TRACE ,
412
452
"collecting paths and path exclusions" ,
413
- "flags.paths" = ?flags . paths ,
414
- "flags.skip" = ?flags . skip ,
415
- "flags.exclude" = ?flags . exclude
453
+ "flags.paths" = ?flags_paths ,
454
+ "flags.skip" = ?flags_skip ,
455
+ "flags.exclude" = ?flags_exclude
416
456
) ;
417
457
418
458
#[ cfg( feature = "tracing" ) ]
@@ -423,28 +463,28 @@ impl Config {
423
463
"config.skip" = ?config. skip,
424
464
) ;
425
465
426
- config. include_default_paths = flags . include_default_paths ;
427
- config. rustc_error_format = flags . rustc_error_format ;
428
- config. json_output = flags . json_output ;
429
- config. on_fail = flags . on_fail ;
430
- config. cmd = flags . cmd ;
431
- config. incremental = flags . incremental ;
432
- config. set_dry_run ( if flags . dry_run { DryRun :: UserSelected } else { DryRun :: Disabled } ) ;
433
- config. dump_bootstrap_shims = flags . dump_bootstrap_shims ;
434
- config. keep_stage = flags . keep_stage ;
435
- config. keep_stage_std = flags . keep_stage_std ;
436
- config. color = flags . color ;
437
- config. free_args = std:: mem:: take ( & mut flags . free_args ) ;
438
- config. llvm_profile_use = flags . llvm_profile_use ;
439
- config. llvm_profile_generate = flags . llvm_profile_generate ;
440
- config. enable_bolt_settings = flags . enable_bolt_settings ;
441
- config. bypass_bootstrap_lock = flags . bypass_bootstrap_lock ;
442
- config. is_running_on_ci = flags . ci . unwrap_or ( CiEnv :: is_ci ( ) ) ;
443
- config. skip_std_check_if_no_download_rustc = flags . skip_std_check_if_no_download_rustc ;
466
+ config. include_default_paths = flags_include_default_paths ;
467
+ config. rustc_error_format = flags_rustc_error_format ;
468
+ config. json_output = flags_json_output ;
469
+ config. on_fail = flags_on_fail ;
470
+ config. cmd = flags_cmd ;
471
+ config. incremental = flags_incremental ;
472
+ config. set_dry_run ( if flags_dry_run { DryRun :: UserSelected } else { DryRun :: Disabled } ) ;
473
+ config. dump_bootstrap_shims = flags_dump_bootstrap_shims ;
474
+ config. keep_stage = flags_keep_stage ;
475
+ config. keep_stage_std = flags_keep_stage_std ;
476
+ config. color = flags_color ;
477
+ config. free_args = std:: mem:: take ( & mut flags_free_args ) ;
478
+ config. llvm_profile_use = flags_llvm_profile_use ;
479
+ config. llvm_profile_generate = flags_llvm_profile_generate ;
480
+ config. enable_bolt_settings = flags_enable_bolt_settings ;
481
+ config. bypass_bootstrap_lock = flags_bypass_bootstrap_lock ;
482
+ config. is_running_on_ci = flags_ci . unwrap_or ( CiEnv :: is_ci ( ) ) ;
483
+ config. skip_std_check_if_no_download_rustc = flags_skip_std_check_if_no_download_rustc ;
444
484
445
485
// Infer the rest of the configuration.
446
486
447
- if let Some ( src) = flags . src {
487
+ if let Some ( src) = flags_src {
448
488
config. src = src
449
489
} else {
450
490
// Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary,
@@ -510,8 +550,7 @@ impl Config {
510
550
// 4. `<root>/bootstrap.toml`
511
551
// 5. `./config.toml` (fallback for backward compatibility)
512
552
// 6. `<root>/config.toml`
513
- let toml_path = flags
514
- . config
553
+ let toml_path = flags_config
515
554
. clone ( )
516
555
. or_else ( || env:: var_os ( "RUST_BOOTSTRAP_CONFIG" ) . map ( PathBuf :: from) ) ;
517
556
let using_default_path = toml_path. is_none ( ) ;
@@ -610,7 +649,7 @@ impl Config {
610
649
}
611
650
612
651
let mut override_toml = TomlConfig :: default ( ) ;
613
- for option in flags . set . iter ( ) {
652
+ for option in flags_set . iter ( ) {
614
653
fn get_table ( option : & str ) -> Result < TomlConfig , toml:: de:: Error > {
615
654
toml:: from_str ( option) . and_then ( |table : toml:: Value | TomlConfig :: deserialize ( table) )
616
655
}
@@ -708,7 +747,7 @@ impl Config {
708
747
exclude,
709
748
} = toml. build . unwrap_or_default ( ) ;
710
749
711
- let mut paths: Vec < PathBuf > = flags . skip . into_iter ( ) . chain ( flags . exclude ) . collect ( ) ;
750
+ let mut paths: Vec < PathBuf > = flags_skip . into_iter ( ) . chain ( flags_exclude ) . collect ( ) ;
712
751
713
752
if let Some ( exclude) = exclude {
714
753
paths. extend ( exclude) ;
@@ -728,15 +767,15 @@ impl Config {
728
767
} )
729
768
. collect ( ) ;
730
769
731
- config. jobs = Some ( threads_from_config ( flags . jobs . unwrap_or ( jobs. unwrap_or ( 0 ) ) ) ) ;
770
+ config. jobs = Some ( threads_from_config ( flags_jobs . unwrap_or ( jobs. unwrap_or ( 0 ) ) ) ) ;
732
771
733
- if let Some ( flags_build) = flags . build {
772
+ if let Some ( flags_build) = flags_build {
734
773
config. host_target = TargetSelection :: from_user ( & flags_build) ;
735
774
} else if let Some ( file_build) = build {
736
775
config. host_target = TargetSelection :: from_user ( & file_build) ;
737
776
} ;
738
777
739
- set ( & mut config. out , flags . build_dir . or_else ( || build_dir. map ( PathBuf :: from) ) ) ;
778
+ set ( & mut config. out , flags_build_dir . or_else ( || build_dir. map ( PathBuf :: from) ) ) ;
740
779
// NOTE: Bootstrap spawns various commands with different working directories.
741
780
// To avoid writing to random places on the file system, `config.out` needs to be an absolute path.
742
781
if !config. out . is_absolute ( ) {
@@ -751,7 +790,7 @@ impl Config {
751
790
}
752
791
753
792
config. initial_rustc = if let Some ( rustc) = rustc {
754
- if !flags . skip_stage0_validation {
793
+ if !flags_skip_stage0_validation {
755
794
config. check_stage0_version ( & rustc, "rustc" ) ;
756
795
}
757
796
rustc
@@ -777,7 +816,7 @@ impl Config {
777
816
config. initial_cargo_clippy = cargo_clippy;
778
817
779
818
config. initial_cargo = if let Some ( cargo) = cargo {
780
- if !flags . skip_stage0_validation {
819
+ if !flags_skip_stage0_validation {
781
820
config. check_stage0_version ( & cargo, "cargo" ) ;
782
821
}
783
822
cargo
@@ -793,14 +832,14 @@ impl Config {
793
832
config. out = dir;
794
833
}
795
834
796
- config. hosts = if let Some ( TargetSelectionList ( arg_host) ) = flags . host {
835
+ config. hosts = if let Some ( TargetSelectionList ( arg_host) ) = flags_host {
797
836
arg_host
798
837
} else if let Some ( file_host) = host {
799
838
file_host. iter ( ) . map ( |h| TargetSelection :: from_user ( h) ) . collect ( )
800
839
} else {
801
840
vec ! [ config. host_target]
802
841
} ;
803
- config. targets = if let Some ( TargetSelectionList ( arg_target) ) = flags . target {
842
+ config. targets = if let Some ( TargetSelectionList ( arg_target) ) = flags_target {
804
843
arg_target
805
844
} else if let Some ( file_target) = target {
806
845
file_target. iter ( ) . map ( |h| TargetSelection :: from_user ( h) ) . collect ( )
@@ -839,7 +878,7 @@ impl Config {
839
878
set ( & mut config. print_step_rusage , print_step_rusage) ;
840
879
config. patch_binaries_for_nix = patch_binaries_for_nix;
841
880
842
- config. verbose = cmp:: max ( config. verbose , flags . verbose as usize ) ;
881
+ config. verbose = cmp:: max ( config. verbose , flags_verbose as usize ) ;
843
882
844
883
// Verbose flag is a good default for `rust.verbose-tests`.
845
884
config. verbose_tests = config. is_verbose ( ) ;
@@ -894,12 +933,12 @@ impl Config {
894
933
config. channel = ci_channel. into ( ) ;
895
934
}
896
935
897
- config. rust_profile_use = flags . rust_profile_use ;
898
- config. rust_profile_generate = flags . rust_profile_generate ;
936
+ config. rust_profile_use = flags_rust_profile_use ;
937
+ config. rust_profile_generate = flags_rust_profile_generate ;
899
938
900
- config. apply_rust_config ( toml. rust , flags . warnings , & mut description) ;
939
+ config. apply_rust_config ( toml. rust , flags_warnings , & mut description) ;
901
940
902
- config. reproducible_artifacts = flags . reproducible_artifact ;
941
+ config. reproducible_artifacts = flags_reproducible_artifact ;
903
942
config. description = description;
904
943
905
944
// We need to override `rust.channel` if it's manually specified when using the CI rustc.
@@ -955,7 +994,7 @@ impl Config {
955
994
956
995
if matches ! ( config. lld_mode, LldMode :: SelfContained )
957
996
&& !config. lld_enabled
958
- && flags . stage . unwrap_or ( 0 ) > 0
997
+ && flags_stage . unwrap_or ( 0 ) > 0
959
998
{
960
999
panic ! (
961
1000
"Trying to use self-contained lld as a linker, but LLD is not being added to the sysroot. Enable it with rust.lld = true."
@@ -974,7 +1013,7 @@ impl Config {
974
1013
config. compiletest_use_stage0_libtest = compiletest_use_stage0_libtest. unwrap_or ( true ) ;
975
1014
976
1015
let download_rustc = config. download_rustc_commit . is_some ( ) ;
977
- config. explicit_stage_from_cli = flags . stage . is_some ( ) ;
1016
+ config. explicit_stage_from_cli = flags_stage . is_some ( ) ;
978
1017
config. explicit_stage_from_config = test_stage. is_some ( )
979
1018
|| build_stage. is_some ( )
980
1019
|| doc_stage. is_some ( )
@@ -984,35 +1023,35 @@ impl Config {
984
1023
|| bench_stage. is_some ( ) ;
985
1024
// See https://github.com/rust-lang/compiler-team/issues/326
986
1025
config. stage = match config. cmd {
987
- Subcommand :: Check { .. } => flags . stage . or ( check_stage) . unwrap_or ( 0 ) ,
988
- Subcommand :: Clippy { .. } | Subcommand :: Fix => flags . stage . or ( check_stage) . unwrap_or ( 1 ) ,
1026
+ Subcommand :: Check { .. } => flags_stage . or ( check_stage) . unwrap_or ( 0 ) ,
1027
+ Subcommand :: Clippy { .. } | Subcommand :: Fix => flags_stage . or ( check_stage) . unwrap_or ( 1 ) ,
989
1028
// `download-rustc` only has a speed-up for stage2 builds. Default to stage2 unless explicitly overridden.
990
1029
Subcommand :: Doc { .. } => {
991
- flags . stage . or ( doc_stage) . unwrap_or ( if download_rustc { 2 } else { 1 } )
1030
+ flags_stage . or ( doc_stage) . unwrap_or ( if download_rustc { 2 } else { 1 } )
992
1031
}
993
1032
Subcommand :: Build => {
994
- flags . stage . or ( build_stage) . unwrap_or ( if download_rustc { 2 } else { 1 } )
1033
+ flags_stage . or ( build_stage) . unwrap_or ( if download_rustc { 2 } else { 1 } )
995
1034
}
996
1035
Subcommand :: Test { .. } | Subcommand :: Miri { .. } => {
997
- flags . stage . or ( test_stage) . unwrap_or ( if download_rustc { 2 } else { 1 } )
1036
+ flags_stage . or ( test_stage) . unwrap_or ( if download_rustc { 2 } else { 1 } )
998
1037
}
999
- Subcommand :: Bench { .. } => flags . stage . or ( bench_stage) . unwrap_or ( 2 ) ,
1000
- Subcommand :: Dist => flags . stage . or ( dist_stage) . unwrap_or ( 2 ) ,
1001
- Subcommand :: Install => flags . stage . or ( install_stage) . unwrap_or ( 2 ) ,
1002
- Subcommand :: Perf { .. } => flags . stage . unwrap_or ( 1 ) ,
1038
+ Subcommand :: Bench { .. } => flags_stage . or ( bench_stage) . unwrap_or ( 2 ) ,
1039
+ Subcommand :: Dist => flags_stage . or ( dist_stage) . unwrap_or ( 2 ) ,
1040
+ Subcommand :: Install => flags_stage . or ( install_stage) . unwrap_or ( 2 ) ,
1041
+ Subcommand :: Perf { .. } => flags_stage . unwrap_or ( 1 ) ,
1003
1042
// These are all bootstrap tools, which don't depend on the compiler.
1004
1043
// The stage we pass shouldn't matter, but use 0 just in case.
1005
1044
Subcommand :: Clean { .. }
1006
1045
| Subcommand :: Run { .. }
1007
1046
| Subcommand :: Setup { .. }
1008
1047
| Subcommand :: Format { .. }
1009
1048
| Subcommand :: Suggest { .. }
1010
- | Subcommand :: Vendor { .. } => flags . stage . unwrap_or ( 0 ) ,
1049
+ | Subcommand :: Vendor { .. } => flags_stage . unwrap_or ( 0 ) ,
1011
1050
} ;
1012
1051
1013
1052
// CI should always run stage 2 builds, unless it specifically states otherwise
1014
1053
#[ cfg( not( test) ) ]
1015
- if flags . stage . is_none ( ) && config. is_running_on_ci {
1054
+ if flags_stage . is_none ( ) && config. is_running_on_ci {
1016
1055
match config. cmd {
1017
1056
Subcommand :: Test { .. }
1018
1057
| Subcommand :: Miri { .. }
0 commit comments