@@ -399,11 +399,11 @@ fn check_existence_of_rustc_or_cargo_in_path(no_prompt: bool) -> Result<()> {
399
399
fn do_pre_install_sanity_checks ( ) -> Result < ( ) > {
400
400
let rustc_manifest_path = PathBuf :: from ( "/usr/local/lib/rustlib/manifest-rustc" ) ;
401
401
let uninstaller_path = PathBuf :: from ( "/usr/local/lib/rustlib/uninstall.sh" ) ;
402
- let rustup_sh_path = utils:: home_dir ( ) . map ( |d| d . join ( ".rustup" ) ) ;
403
- let rustup_sh_version_path = rustup_sh_path. as_ref ( ) . map ( |p| p . join ( "rustup-version" ) ) ;
402
+ let rustup_sh_path = utils:: home_dir ( ) . unwrap ( ) . join ( ".rustup" ) ;
403
+ let rustup_sh_version_path = rustup_sh_path. join ( "rustup-version" ) ;
404
404
405
405
let rustc_exists = rustc_manifest_path. exists ( ) && uninstaller_path. exists ( ) ;
406
- let rustup_sh_exists = rustup_sh_version_path. map ( |p| p . exists ( ) ) == Some ( true ) ;
406
+ let rustup_sh_exists = rustup_sh_version_path. exists ( ) ;
407
407
408
408
if rustc_exists {
409
409
warn ! ( "it looks like you have an existing installation of Rust" ) ;
@@ -418,10 +418,7 @@ fn do_pre_install_sanity_checks() -> Result<()> {
418
418
if rustup_sh_exists {
419
419
warn ! ( "it looks like you have existing rustup.sh metadata" ) ;
420
420
warn ! ( "rustup cannot be installed while rustup.sh metadata exists" ) ;
421
- warn ! (
422
- "delete `{}` to remove rustup.sh" ,
423
- rustup_sh_path. unwrap( ) . display( )
424
- ) ;
421
+ warn ! ( "delete `{}` to remove rustup.sh" , rustup_sh_path. display( ) ) ;
425
422
warn ! ( "or, if you already have rustup installed, you can run" ) ;
426
423
warn ! ( "`rustup self update` and `rustup toolchain list` to upgrade" ) ;
427
424
warn ! ( "your directory structure" ) ;
@@ -711,7 +708,7 @@ pub fn install_proxies() -> Result<()> {
711
708
if tool_handles. iter ( ) . all ( |h| * h != handle) {
712
709
warn ! ( "tool `{}` is already installed, remove it from `{}`, then run `rustup update` \
713
710
to have rustup manage this tool.",
714
- tool, bin_path. to_string_lossy ( ) ) ;
711
+ tool, bin_path. display ( ) ) ;
715
712
continue ;
716
713
}
717
714
}
@@ -1094,30 +1091,27 @@ fn get_add_path_methods() -> Vec<PathUpdateMethod> {
1094
1091
return vec ! [ PathUpdateMethod :: Windows ] ;
1095
1092
}
1096
1093
1097
- let profile = utils:: home_dir ( ) . map ( |p| p. join ( ".profile" ) ) ;
1094
+ let home_dir = utils:: home_dir ( ) . unwrap ( ) ;
1095
+ let profile = home_dir. join ( ".profile" ) ;
1098
1096
let mut profiles = vec ! [ profile] ;
1099
1097
1100
1098
if let Ok ( shell) = env:: var ( "SHELL" ) {
1101
1099
if shell. contains ( "zsh" ) {
1102
- let zdotdir = env:: var ( "ZDOTDIR" )
1103
- . ok ( )
1104
- . map ( PathBuf :: from)
1105
- . or_else ( utils:: home_dir) ;
1106
- let zprofile = zdotdir. map ( |p| p. join ( ".zprofile" ) ) ;
1100
+ let var = env:: var_os ( "ZDOTDIR" ) ;
1101
+ let zdotdir = var. as_deref ( ) . map_or_else ( || home_dir. as_path ( ) , Path :: new) ;
1102
+ let zprofile = zdotdir. join ( ".zprofile" ) ;
1107
1103
profiles. push ( zprofile) ;
1108
1104
}
1109
1105
}
1110
1106
1111
- if let Some ( bash_profile) = utils:: home_dir ( ) . map ( |p| p. join ( ".bash_profile" ) ) {
1112
- // Only update .bash_profile if it exists because creating .bash_profile
1113
- // will cause .profile to not be read
1114
- if bash_profile. exists ( ) {
1115
- profiles. push ( Some ( bash_profile) ) ;
1116
- }
1107
+ let bash_profile = home_dir. join ( ".bash_profile" ) ;
1108
+ // Only update .bash_profile if it exists because creating .bash_profile
1109
+ // will cause .profile to not be read
1110
+ if bash_profile. exists ( ) {
1111
+ profiles. push ( bash_profile) ;
1117
1112
}
1118
1113
1119
- let rcfiles = profiles. into_iter ( ) . filter_map ( |f| f) ;
1120
- rcfiles. map ( PathUpdateMethod :: RcFile ) . collect ( )
1114
+ profiles. into_iter ( ) . map ( PathUpdateMethod :: RcFile ) . collect ( )
1121
1115
}
1122
1116
1123
1117
fn shell_export_string ( ) -> Result < String > {
0 commit comments