@@ -71,6 +71,7 @@ pub struct InstallOpts<'a> {
71
71
pub default_toolchain : Option < String > ,
72
72
pub profile : String ,
73
73
pub no_modify_path : bool ,
74
+ pub no_update_toolchain : bool ,
74
75
pub components : & ' a [ & ' a str ] ,
75
76
pub targets : & ' a [ & ' a str ] ,
76
77
}
@@ -328,6 +329,7 @@ pub fn install(
328
329
opts. default_toolchain . as_deref ( ) ,
329
330
& opts. profile ,
330
331
opts. default_host_triple . as_deref ( ) ,
332
+ !opts. no_update_toolchain ,
331
333
opts. components ,
332
334
opts. targets ,
333
335
verbose,
@@ -712,6 +714,7 @@ fn maybe_install_rust(
712
714
toolchain : Option < & str > ,
713
715
profile_str : & str ,
714
716
default_host_triple : Option < & str > ,
717
+ update_existing_toolchain : bool ,
715
718
components : & [ & str ] ,
716
719
targets : & [ & str ] ,
717
720
verbose : bool ,
@@ -728,8 +731,10 @@ fn maybe_install_rust(
728
731
info ! ( "default host triple is {}" , cfg. get_default_host_triple( ) ?) ;
729
732
}
730
733
731
- let user_specified_something =
732
- toolchain. is_some ( ) || !targets. is_empty ( ) || !components. is_empty ( ) ;
734
+ let user_specified_something = toolchain. is_some ( )
735
+ || !targets. is_empty ( )
736
+ || !components. is_empty ( )
737
+ || update_existing_toolchain;
733
738
734
739
// If the user specified they want no toolchain, we skip this, otherwise
735
740
// if they specify something directly, or we have no default, then we install
@@ -754,16 +759,21 @@ fn maybe_install_rust(
754
759
}
755
760
writeln ! ( process( ) . stdout( ) ) ?;
756
761
} else if user_specified_something || cfg. find_default ( ) ?. is_none ( ) {
757
- let toolchain_str = toolchain. unwrap_or ( "stable" ) ;
758
- let toolchain = cfg. get_toolchain ( toolchain_str, false ) ?;
762
+ let ( toolchain_str, toolchain) = match toolchain {
763
+ Some ( s) => ( s. to_owned ( ) , cfg. get_toolchain ( s, false ) ?) ,
764
+ None => match cfg. find_default ( ) ? {
765
+ Some ( t) => ( t. name ( ) . to_owned ( ) , t) ,
766
+ None => ( "stable" . to_owned ( ) , cfg. get_toolchain ( "stable" , false ) ?) ,
767
+ } ,
768
+ } ;
759
769
if toolchain. exists ( ) {
760
770
warn ! ( "Updating existing toolchain, profile choice will be ignored" ) ;
761
771
}
762
772
let distributable = DistributableToolchain :: new ( & toolchain) ?;
763
773
let status = distributable. install_from_dist ( true , false , components, targets) ?;
764
- cfg. set_default ( toolchain_str) ?;
774
+ cfg. set_default ( & toolchain_str) ?;
765
775
writeln ! ( process( ) . stdout( ) ) ?;
766
- common:: show_channel_update ( & cfg, toolchain_str, Ok ( status) ) ?;
776
+ common:: show_channel_update ( & cfg, & toolchain_str, Ok ( status) ) ?;
767
777
} else {
768
778
info ! ( "updating existing rustup installation - leaving toolchains alone" ) ;
769
779
writeln ! ( process( ) . stdout( ) ) ?;
0 commit comments