@@ -28,7 +28,6 @@ use super::{
28
28
#[ derive( Debug ) ]
29
29
pub ( crate ) struct DistributableToolchain < ' a > {
30
30
pub ( super ) toolchain : Toolchain < ' a > ,
31
- cfg : & ' a Cfg < ' a > ,
32
31
desc : ToolchainDesc ,
33
32
}
34
33
@@ -43,11 +42,7 @@ impl<'a> DistributableToolchain<'a> {
43
42
}
44
43
45
44
pub ( crate ) fn new ( cfg : & ' a Cfg < ' a > , desc : ToolchainDesc ) -> Result < Self , RustupError > {
46
- Toolchain :: new ( cfg, ( & desc) . into ( ) ) . map ( |toolchain| Self {
47
- toolchain,
48
- cfg,
49
- desc,
50
- } )
45
+ Toolchain :: new ( cfg, ( & desc) . into ( ) ) . map ( |toolchain| Self { toolchain, desc } )
51
46
}
52
47
53
48
pub ( crate ) fn desc ( & self ) -> & ToolchainDesc {
@@ -109,8 +104,8 @@ impl<'a> DistributableToolchain<'a> {
109
104
} ;
110
105
111
106
let notify_handler =
112
- & |n : crate :: dist:: Notification < ' _ > | ( self . cfg . notify_handler ) ( n. into ( ) ) ;
113
- let download_cfg = self . cfg . download_cfg ( & notify_handler) ;
107
+ & |n : crate :: dist:: Notification < ' _ > | ( self . toolchain . cfg . notify_handler ) ( n. into ( ) ) ;
108
+ let download_cfg = self . toolchain . cfg . download_cfg ( & notify_handler) ;
114
109
115
110
manifestation
116
111
. update (
@@ -204,7 +199,7 @@ impl<'a> DistributableToolchain<'a> {
204
199
// it to do that, because cargo's directory contains the _wrong_ rustc. See
205
200
// the documentation for the lpCommandLine argument of CreateProcess.
206
201
let exe_path = if cfg ! ( windows) {
207
- let fallback_dir = self . cfg . rustup_dir . join ( "fallback" ) ;
202
+ let fallback_dir = self . toolchain . cfg . rustup_dir . join ( "fallback" ) ;
208
203
fs:: create_dir_all ( & fallback_dir)
209
204
. context ( "unable to create dir to hold fallback exe" ) ?;
210
205
let fallback_file = fallback_dir. join ( "cargo.exe" ) ;
@@ -413,17 +408,16 @@ impl<'a> DistributableToolchain<'a> {
413
408
} )
414
409
. ok ( ) ;
415
410
416
- let hash_path = self . cfg . get_hash_file ( & self . desc , true ) ?;
411
+ let cfg = self . toolchain . cfg ;
412
+ let hash_path = cfg. get_hash_file ( & self . desc , true ) ?;
417
413
let update_hash = Some ( & hash_path as & Path ) ;
418
414
419
415
InstallMethod :: Dist {
420
- cfg : self . cfg ,
416
+ cfg,
421
417
desc : & self . desc ,
422
418
profile,
423
419
update_hash,
424
- dl_cfg : self
425
- . cfg
426
- . download_cfg ( & |n| ( self . cfg . notify_handler ) ( n. into ( ) ) ) ,
420
+ dl_cfg : cfg. download_cfg ( & |n| ( cfg. notify_handler ) ( n. into ( ) ) ) ,
427
421
force,
428
422
allow_downgrade,
429
423
exists : true ,
@@ -456,7 +450,7 @@ impl<'a> DistributableToolchain<'a> {
456
450
"the '{binary_lossy}' binary, normally provided by the '{short_name}' component, is not applicable to the '{desc}' toolchain" ) )
457
451
} else {
458
452
// available, not installed, recommend installation
459
- let selector = match self . cfg . get_default ( ) ? {
453
+ let selector = match self . toolchain . cfg . get_default ( ) ? {
460
454
Some ( ToolchainName :: Official ( n) ) if n == self . desc => String :: new ( ) ,
461
455
_ => format ! ( "--toolchain {} " , self . toolchain. name( ) ) ,
462
456
} ;
@@ -516,8 +510,8 @@ impl<'a> DistributableToolchain<'a> {
516
510
} ;
517
511
518
512
let notify_handler =
519
- & |n : crate :: dist:: Notification < ' _ > | ( self . cfg . notify_handler ) ( n. into ( ) ) ;
520
- let download_cfg = self . cfg . download_cfg ( & notify_handler) ;
513
+ & |n : crate :: dist:: Notification < ' _ > | ( self . toolchain . cfg . notify_handler ) ( n. into ( ) ) ;
514
+ let download_cfg = self . toolchain . cfg . download_cfg ( & notify_handler) ;
521
515
522
516
manifestation
523
517
. update (
@@ -534,10 +528,10 @@ impl<'a> DistributableToolchain<'a> {
534
528
}
535
529
536
530
pub async fn show_dist_version ( & self ) -> anyhow:: Result < Option < String > > {
537
- let update_hash = self . cfg . get_hash_file ( & self . desc , false ) ?;
531
+ let update_hash = self . toolchain . cfg . get_hash_file ( & self . desc , false ) ?;
538
532
let notify_handler =
539
- & |n : crate :: dist:: Notification < ' _ > | ( self . cfg . notify_handler ) ( n. into ( ) ) ;
540
- let download_cfg = self . cfg . download_cfg ( & notify_handler) ;
533
+ & |n : crate :: dist:: Notification < ' _ > | ( self . toolchain . cfg . notify_handler ) ( n. into ( ) ) ;
534
+ let download_cfg = self . toolchain . cfg . download_cfg ( & notify_handler) ;
541
535
542
536
match crate :: dist:: dl_v2_manifest ( download_cfg, Some ( & update_hash) , & self . desc ) . await ? {
543
537
Some ( ( manifest, _) ) => Ok ( Some ( manifest. get_rust_version ( ) ?. to_string ( ) ) ) ,
@@ -574,7 +568,6 @@ impl<'a> TryFrom<&Toolchain<'a>> for DistributableToolchain<'a> {
574
568
match value. name ( ) {
575
569
LocalToolchainName :: Named ( ToolchainName :: Official ( desc) ) => Ok ( Self {
576
570
toolchain : value. clone ( ) ,
577
- cfg : value. cfg ,
578
571
desc : desc. clone ( ) ,
579
572
} ) ,
580
573
n => Err ( RustupError :: ComponentsUnsupported ( n. to_string ( ) ) ) ,
0 commit comments