@@ -508,50 +508,49 @@ fn canonical_cargo_home(process: &Process) -> Result<Cow<'static, str>> {
508508/// `CARGO_HOME`/bin, hard-linking the various Rust tools to it,
509509/// and adding `CARGO_HOME`/bin to PATH.
510510pub ( crate ) async fn install (
511- current_dir : PathBuf ,
512511 no_prompt : bool ,
513- quiet : bool ,
514512 mut opts : InstallOpts < ' _ > ,
515- process : & Process ,
513+ cfg : & mut Cfg < ' _ > ,
516514) -> Result < utils:: ExitCode > {
517515 #[ cfg_attr( not( unix) , allow( unused_mut) ) ]
518516 let mut exit_code = utils:: ExitCode ( 0 ) ;
519517
520- opts. validate ( process) . map_err ( |e| {
518+ opts. validate ( cfg . process ) . map_err ( |e| {
521519 anyhow ! (
522520 "Pre-checks for host and toolchain failed: {e}\n \
523521 If you are unsure of suitable values, the 'stable' toolchain is the default.\n \
524522 Valid host triples look something like: {}",
525- TargetTriple :: from_host_or_build( process)
523+ TargetTriple :: from_host_or_build( cfg . process)
526524 )
527525 } ) ?;
528526
529- if process
527+ if cfg
528+ . process
530529 . var_os ( "RUSTUP_INIT_SKIP_EXISTENCE_CHECKS" )
531530 . is_none_or ( |s| s != "yes" )
532531 {
533- check_existence_of_rustc_or_cargo_in_path ( no_prompt, process) ?;
534- check_existence_of_settings_file ( process) ?;
532+ check_existence_of_rustc_or_cargo_in_path ( no_prompt, cfg . process ) ?;
533+ check_existence_of_settings_file ( cfg . process ) ?;
535534 }
536535
537536 #[ cfg( unix) ]
538537 {
539- exit_code &= unix:: do_anti_sudo_check ( no_prompt, process) ?;
538+ exit_code &= unix:: do_anti_sudo_check ( no_prompt, cfg . process ) ?;
540539 }
541540
542- let mut term = process. stdout ( ) ;
541+ let mut term = cfg . process . stdout ( ) ;
543542
544543 #[ cfg( windows) ]
545544 windows:: maybe_install_msvc ( & mut term, no_prompt, quiet, & opts, process) . await ?;
546545
547546 if !no_prompt {
548- let msg = pre_install_msg ( opts. no_modify_path , process) ?;
547+ let msg = pre_install_msg ( opts. no_modify_path , cfg . process ) ?;
549548
550549 md ( & mut term, msg) ;
551550 let mut customized_install = false ;
552551 loop {
553- md ( & mut term, current_install_opts ( & opts, process) ) ;
554- match common:: confirm_advanced ( customized_install, process) ? {
552+ md ( & mut term, current_install_opts ( & opts, cfg . process ) ) ;
553+ match common:: confirm_advanced ( customized_install, cfg . process ) ? {
555554 Confirm :: No => {
556555 info ! ( "aborting installation" ) ;
557556 return Ok ( utils:: ExitCode ( 0 ) ) ;
@@ -561,15 +560,15 @@ pub(crate) async fn install(
561560 }
562561 Confirm :: Advanced => {
563562 customized_install = true ;
564- opts. customize ( process) ?;
563+ opts. customize ( cfg . process ) ?;
565564 }
566565 }
567566 }
568567 }
569568
570569 let no_modify_path = opts. no_modify_path ;
571- if let Err ( e) = maybe_install_rust ( current_dir , quiet , opts, process ) . await {
572- report_error ( & e, process) ;
570+ if let Err ( e) = maybe_install_rust ( opts, cfg ) . await {
571+ report_error ( & e, cfg . process ) ;
573572
574573 // On windows, where installation happens in a console
575574 // that may have opened just for this purpose, give
@@ -583,7 +582,7 @@ pub(crate) async fn install(
583582 return Ok ( utils:: ExitCode ( 1 ) ) ;
584583 }
585584
586- let cargo_home = canonical_cargo_home ( process) ?;
585+ let cargo_home = canonical_cargo_home ( cfg . process ) ?;
587586 #[ cfg( windows) ]
588587 let cargo_home = cargo_home. replace ( '\\' , r"\\" ) ;
589588 #[ cfg( windows) ]
@@ -596,7 +595,7 @@ pub(crate) async fn install(
596595 format ! ( post_install_msg_win!( ) , cargo_home = cargo_home)
597596 } ;
598597 #[ cfg( not( windows) ) ]
599- let cargo_home_nushell = Nu . cargo_home_str ( process) ?;
598+ let cargo_home_nushell = Nu . cargo_home_str ( cfg . process ) ?;
600599 #[ cfg( not( windows) ) ]
601600 let msg = if no_modify_path {
602601 format ! (
@@ -614,7 +613,7 @@ pub(crate) async fn install(
614613 md ( & mut term, msg) ;
615614
616615 #[ cfg( unix) ]
617- warn_if_default_linker_missing ( process) ;
616+ warn_if_default_linker_missing ( cfg . process ) ;
618617
619618 #[ cfg( windows) ]
620619 if !no_prompt {
@@ -911,35 +910,29 @@ fn check_proxy_sanity(process: &Process, components: &[&str], desc: &ToolchainDe
911910 Ok ( ( ) )
912911}
913912
914- async fn maybe_install_rust (
915- current_dir : PathBuf ,
916- quiet : bool ,
917- opts : InstallOpts < ' _ > ,
918- process : & Process ,
919- ) -> Result < ( ) > {
920- install_bins ( process) ?;
913+ async fn maybe_install_rust ( opts : InstallOpts < ' _ > , cfg : & mut Cfg < ' _ > ) -> Result < ( ) > {
914+ install_bins ( cfg. process ) ?;
921915
922916 #[ cfg( unix) ]
923- unix:: do_write_env_files ( process) ?;
917+ unix:: do_write_env_files ( cfg . process ) ?;
924918
925919 if !opts. no_modify_path {
926- do_add_to_path ( process) ?;
920+ do_add_to_path ( cfg . process ) ?;
927921 }
928922
929923 // If RUSTUP_HOME is not set, make sure it exists
930- if process. var_os ( "RUSTUP_HOME" ) . is_none ( ) {
931- let home = process
924+ if cfg. process . var_os ( "RUSTUP_HOME" ) . is_none ( ) {
925+ let home = cfg
926+ . process
932927 . home_dir ( )
933928 . map ( |p| p. join ( ".rustup" ) )
934929 . ok_or_else ( || anyhow:: anyhow!( "could not find home dir to put .rustup in" ) ) ?;
935930
936931 fs:: create_dir_all ( home) . context ( "unable to create ~/.rustup" ) ?;
937932 }
938933
939- let mut cfg = common:: set_globals ( current_dir, quiet, process) ?;
940-
941934 let ( components, targets) = ( opts. components , opts. targets ) ;
942- let toolchain = opts. install ( & mut cfg) ?;
935+ let toolchain = opts. install ( cfg) ?;
943936 if let Some ( desc) = & toolchain {
944937 let status = if Toolchain :: exists ( & cfg, & desc. into ( ) ) ? {
945938 warn ! ( "Updating existing toolchain, profile choice will be ignored" ) ;
@@ -965,10 +958,10 @@ async fn maybe_install_rust(
965958 . 0
966959 } ;
967960
968- check_proxy_sanity ( process, components, desc) ?;
961+ check_proxy_sanity ( cfg . process , components, desc) ?;
969962
970963 cfg. set_default ( Some ( & desc. into ( ) ) ) ?;
971- writeln ! ( process. stdout( ) . lock( ) ) ?;
964+ writeln ! ( cfg . process. stdout( ) . lock( ) ) ?;
972965 common:: show_channel_update ( & cfg, PackageUpdate :: Toolchain ( desc. clone ( ) ) , Ok ( status) ) ?;
973966 }
974967 Ok ( ( ) )
0 commit comments