30
30
//! Deleting the running binary during uninstall is tricky
31
31
//! and racy on Windows.
32
32
33
- #[ cfg( unix) ]
34
- mod shell;
35
- #[ cfg( feature = "test" ) ]
36
- pub ( crate ) mod test;
37
- #[ cfg( unix) ]
38
- mod unix;
39
- #[ cfg( windows) ]
40
- mod windows;
41
- mod os {
42
- #[ cfg( unix) ]
43
- pub ( crate ) use super :: unix:: * ;
44
- #[ cfg( windows) ]
45
- pub ( crate ) use super :: windows:: * ;
46
- }
47
-
48
33
use std:: borrow:: Cow ;
49
34
use std:: env:: consts:: EXE_SUFFIX ;
50
35
use std:: fs;
@@ -82,10 +67,26 @@ use crate::{
82
67
DUP_TOOLS , TOOLS ,
83
68
} ;
84
69
85
- use os:: * ;
86
- pub ( crate ) use os:: { run_update, self_replace} ;
70
+ #[ cfg( unix) ]
71
+ mod shell;
72
+ #[ cfg( feature = "test" ) ]
73
+ pub ( crate ) mod test;
74
+
75
+ #[ cfg( unix) ]
76
+ mod unix;
77
+ #[ cfg( unix) ]
78
+ use unix:: { delete_rustup_and_cargo_home, do_add_to_path, do_remove_from_path} ;
79
+ #[ cfg( unix) ]
80
+ pub ( crate ) use unix:: { run_update, self_replace} ;
81
+
82
+ #[ cfg( windows) ]
83
+ mod windows;
87
84
#[ cfg( windows) ]
88
85
pub use windows:: complete_windows_uninstall;
86
+ #[ cfg( windows) ]
87
+ use windows:: { delete_rustup_and_cargo_home, do_add_to_path, do_remove_from_path} ;
88
+ #[ cfg( windows) ]
89
+ pub ( crate ) use windows:: { run_update, self_replace} ;
89
90
90
91
pub ( crate ) struct InstallOpts < ' a > {
91
92
pub default_host_triple : Option < String > ,
@@ -557,19 +558,20 @@ pub(crate) async fn install(
557
558
}
558
559
559
560
#[ cfg( unix) ]
560
- do_anti_sudo_check ( no_prompt, process) ?;
561
+ unix :: do_anti_sudo_check ( no_prompt, process) ?;
561
562
562
563
let mut term = process. stdout ( ) . terminal ( process) ;
563
564
564
565
#[ cfg( windows) ]
565
- if let Some ( plan) = do_msvc_check ( & opts, process) {
566
+ if let Some ( plan) = windows:: do_msvc_check ( & opts, process) {
567
+ use windows:: { VsInstallPlan , ContinueInstall } ;
566
568
if no_prompt {
567
569
warn ! ( "installing msvc toolchain without its prerequisites" ) ;
568
570
} else if !quiet && plan == VsInstallPlan :: Automatic {
569
571
md ( & mut term, MSVC_AUTO_INSTALL_MESSAGE ) ;
570
572
match windows:: choose_vs_install ( process) ? {
571
573
Some ( VsInstallPlan :: Automatic ) => {
572
- match try_install_msvc ( & opts, process) . await {
574
+ match windows :: try_install_msvc ( & opts, process) . await {
573
575
Err ( e) => {
574
576
// Make sure the console doesn't exit before the user can
575
577
// see the error and give the option to continue anyway.
@@ -580,7 +582,7 @@ pub(crate) async fn install(
580
582
}
581
583
}
582
584
Ok ( ContinueInstall :: No ) => {
583
- ensure_prompt ( process) ?;
585
+ windows :: ensure_prompt ( process) ?;
584
586
return Ok ( utils:: ExitCode ( 0 ) ) ;
585
587
}
586
588
_ => { }
@@ -638,7 +640,7 @@ pub(crate) async fn install(
638
640
// window closes.
639
641
#[ cfg( windows) ]
640
642
if !no_prompt {
641
- ensure_prompt ( process) ?;
643
+ windows :: ensure_prompt ( process) ?;
642
644
}
643
645
644
646
return Ok ( utils:: ExitCode ( 1 ) ) ;
@@ -672,7 +674,7 @@ pub(crate) async fn install(
672
674
// On windows, where installation happens in a console
673
675
// that may have opened just for this purpose, require
674
676
// the user to press a key to continue.
675
- ensure_prompt ( process) ?;
677
+ windows :: ensure_prompt ( process) ?;
676
678
}
677
679
678
680
Ok ( utils:: ExitCode ( 0 ) )
@@ -928,11 +930,11 @@ async fn maybe_install_rust(
928
930
install_bins ( process) ?;
929
931
930
932
#[ cfg( unix) ]
931
- do_write_env_files ( process) ?;
933
+ unix :: do_write_env_files ( process) ?;
932
934
933
935
if !opts. no_modify_path {
934
936
#[ cfg( windows) ]
935
- do_add_to_programs ( process) ?;
937
+ windows :: do_add_to_programs ( process) ?;
936
938
do_add_to_path ( process) ?;
937
939
}
938
940
@@ -1021,7 +1023,7 @@ pub(crate) fn uninstall(no_prompt: bool, process: &Process) -> Result<utils::Exi
1021
1023
// Remove CARGO_HOME/bin from PATH
1022
1024
do_remove_from_path ( process) ?;
1023
1025
#[ cfg( windows) ]
1024
- do_remove_from_programs ( ) ?;
1026
+ windows :: do_remove_from_programs ( ) ?;
1025
1027
1026
1028
// Delete everything in CARGO_HOME *except* the rustup bin
1027
1029
0 commit comments