@@ -500,13 +500,23 @@ pub(crate) fn do_remove_from_path() -> Result<()> {
500
500
501
501
const RUSTUP_UNINSTALL_ENTRY : & str = r"Software\Microsoft\Windows\CurrentVersion\Uninstall\Rustup" ;
502
502
503
+ fn rustup_uninstall_reg_key ( ) -> Result < RegKey > {
504
+ Ok ( RegKey :: predef ( HKEY_CURRENT_USER )
505
+ . create_subkey ( RUSTUP_UNINSTALL_ENTRY )
506
+ . context ( "Failed creating uninstall key" ) ?
507
+ . 0 )
508
+ }
509
+
510
+ pub ( crate ) fn do_update_programs_display_version ( version : & str ) -> Result < ( ) > {
511
+ rustup_uninstall_reg_key ( ) ?
512
+ . set_value ( "DisplayVersion" , & version)
513
+ . context ( "Failed to set display version" )
514
+ }
515
+
503
516
pub ( crate ) fn do_add_to_programs ( ) -> Result < ( ) > {
504
517
use std:: path:: PathBuf ;
505
518
506
- let key = RegKey :: predef ( HKEY_CURRENT_USER )
507
- . create_subkey ( RUSTUP_UNINSTALL_ENTRY )
508
- . context ( "Failed creating uninstall key" ) ?
509
- . 0 ;
519
+ let key = rustup_uninstall_reg_key ( ) ?;
510
520
511
521
// Don't overwrite registry if Rustup is already installed
512
522
let prev = key
@@ -531,14 +541,11 @@ pub(crate) fn do_add_to_programs() -> Result<()> {
531
541
vtype : RegType :: REG_SZ ,
532
542
} ;
533
543
534
- let current_version: & str = env ! ( "CARGO_PKG_VERSION" ) ;
535
-
536
544
key. set_raw_value ( "UninstallString" , & reg_value)
537
545
. context ( "Failed to set uninstall string" ) ?;
538
546
key. set_value ( "DisplayName" , & "Rustup: the Rust toolchain installer" )
539
547
. context ( "Failed to set display name" ) ?;
540
- key. set_value ( "DisplayVersion" , & current_version)
541
- . context ( "Failed to set display version" ) ?;
548
+ do_update_programs_display_version ( env ! ( "CARGO_PKG_VERSION" ) ) ?;
542
549
543
550
Ok ( ( ) )
544
551
}
0 commit comments