@@ -659,69 +659,6 @@ impl<'a> Toolchain<'a> {
659
659
None
660
660
}
661
661
}
662
- // Distributable only. Installed only.
663
- pub fn add_component ( & self , mut component : Component ) -> Result < ( ) > {
664
- if !self . exists ( ) {
665
- return Err ( ErrorKind :: ToolchainNotInstalled ( self . name . to_owned ( ) ) . into ( ) ) ;
666
- }
667
-
668
- let toolchain = & self . name ;
669
- let toolchain = ToolchainDesc :: from_str ( toolchain)
670
- . chain_err ( || ErrorKind :: ComponentsUnsupported ( self . name . to_string ( ) ) ) ?;
671
-
672
- let prefix = InstallPrefix :: from ( self . path . to_owned ( ) ) ;
673
- let manifestation = Manifestation :: open ( prefix, toolchain. target . clone ( ) ) ?;
674
-
675
- if let Some ( manifest) = manifestation. load_manifest ( ) ? {
676
- // Rename the component if necessary.
677
- if let Some ( c) = manifest. rename_component ( & component) {
678
- component = c;
679
- }
680
-
681
- // Validate the component name
682
- let rust_pkg = manifest
683
- . packages
684
- . get ( "rust" )
685
- . expect ( "manifest should contain a rust package" ) ;
686
- let targ_pkg = rust_pkg
687
- . targets
688
- . get ( & toolchain. target )
689
- . expect ( "installed manifest should have a known target" ) ;
690
-
691
- if !targ_pkg. components . contains ( & component) {
692
- let wildcard_component = component. wildcard ( ) ;
693
- if targ_pkg. components . contains ( & wildcard_component) {
694
- component = wildcard_component;
695
- } else {
696
- return Err ( ErrorKind :: UnknownComponent (
697
- self . name . to_string ( ) ,
698
- component. description ( & manifest) ,
699
- self . get_component_suggestion ( & component, & manifest, false ) ,
700
- )
701
- . into ( ) ) ;
702
- }
703
- }
704
-
705
- let changes = Changes {
706
- explicit_add_components : vec ! [ component] ,
707
- remove_components : vec ! [ ] ,
708
- } ;
709
-
710
- manifestation. update (
711
- & manifest,
712
- changes,
713
- false ,
714
- & self . download_cfg ( ) ,
715
- & self . download_cfg ( ) . notify_handler ,
716
- & toolchain. manifest_name ( ) ,
717
- false ,
718
- ) ?;
719
-
720
- Ok ( ( ) )
721
- } else {
722
- Err ( ErrorKind :: ComponentsUnsupported ( self . name . to_string ( ) ) . into ( ) )
723
- }
724
- }
725
662
// Distributable and Custom. Installed only.
726
663
pub fn binary_file ( & self , name : & str ) -> PathBuf {
727
664
let mut path = self . path . clone ( ) ;
@@ -797,6 +734,71 @@ impl<'a> DistributableToolchain<'a> {
797
734
}
798
735
}
799
736
737
+ // Installed only.
738
+ pub fn add_component ( & self , mut component : Component ) -> Result < ( ) > {
739
+ if !self . 0 . exists ( ) {
740
+ return Err ( ErrorKind :: ToolchainNotInstalled ( self . 0 . name . to_owned ( ) ) . into ( ) ) ;
741
+ }
742
+
743
+ let toolchain = & self . 0 . name ;
744
+ let toolchain = ToolchainDesc :: from_str ( toolchain)
745
+ . chain_err ( || ErrorKind :: ComponentsUnsupported ( self . 0 . name . to_string ( ) ) ) ?;
746
+
747
+ let prefix = InstallPrefix :: from ( self . 0 . path . to_owned ( ) ) ;
748
+ let manifestation = Manifestation :: open ( prefix, toolchain. target . clone ( ) ) ?;
749
+
750
+ if let Some ( manifest) = manifestation. load_manifest ( ) ? {
751
+ // Rename the component if necessary.
752
+ if let Some ( c) = manifest. rename_component ( & component) {
753
+ component = c;
754
+ }
755
+
756
+ // Validate the component name
757
+ let rust_pkg = manifest
758
+ . packages
759
+ . get ( "rust" )
760
+ . expect ( "manifest should contain a rust package" ) ;
761
+ let targ_pkg = rust_pkg
762
+ . targets
763
+ . get ( & toolchain. target )
764
+ . expect ( "installed manifest should have a known target" ) ;
765
+
766
+ if !targ_pkg. components . contains ( & component) {
767
+ let wildcard_component = component. wildcard ( ) ;
768
+ if targ_pkg. components . contains ( & wildcard_component) {
769
+ component = wildcard_component;
770
+ } else {
771
+ return Err ( ErrorKind :: UnknownComponent (
772
+ self . 0 . name . to_string ( ) ,
773
+ component. description ( & manifest) ,
774
+ self . 0
775
+ . get_component_suggestion ( & component, & manifest, false ) ,
776
+ )
777
+ . into ( ) ) ;
778
+ }
779
+ }
780
+
781
+ let changes = Changes {
782
+ explicit_add_components : vec ! [ component] ,
783
+ remove_components : vec ! [ ] ,
784
+ } ;
785
+
786
+ manifestation. update (
787
+ & manifest,
788
+ changes,
789
+ false ,
790
+ & self . 0 . download_cfg ( ) ,
791
+ & self . 0 . download_cfg ( ) . notify_handler ,
792
+ & toolchain. manifest_name ( ) ,
793
+ false ,
794
+ ) ?;
795
+
796
+ Ok ( ( ) )
797
+ } else {
798
+ Err ( ErrorKind :: ComponentsUnsupported ( self . 0 . name . to_string ( ) ) . into ( ) )
799
+ }
800
+ }
801
+
800
802
// Installed only.
801
803
fn get_manifest ( & self ) -> Result < Option < Manifest > > {
802
804
if !self . 0 . exists ( ) {
0 commit comments