@@ -722,60 +722,6 @@ impl<'a> Toolchain<'a> {
722
722
Err ( ErrorKind :: ComponentsUnsupported ( self . name . to_string ( ) ) . into ( ) )
723
723
}
724
724
}
725
- // Distributable only. Installed only.
726
- pub fn remove_component ( & self , mut component : Component ) -> Result < ( ) > {
727
- if !self . exists ( ) {
728
- return Err ( ErrorKind :: ToolchainNotInstalled ( self . name . to_owned ( ) ) . into ( ) ) ;
729
- }
730
-
731
- let toolchain = & self . name ;
732
- let toolchain = ToolchainDesc :: from_str ( toolchain)
733
- . chain_err ( || ErrorKind :: ComponentsUnsupported ( self . name . to_string ( ) ) ) ?;
734
-
735
- let prefix = InstallPrefix :: from ( self . path . to_owned ( ) ) ;
736
- let manifestation = Manifestation :: open ( prefix, toolchain. target . clone ( ) ) ?;
737
-
738
- if let Some ( manifest) = manifestation. load_manifest ( ) ? {
739
- // Rename the component if necessary.
740
- if let Some ( c) = manifest. rename_component ( & component) {
741
- component = c;
742
- }
743
-
744
- let dist_config = manifestation. read_config ( ) ?. unwrap ( ) ;
745
- if !dist_config. components . contains ( & component) {
746
- let wildcard_component = component. wildcard ( ) ;
747
- if dist_config. components . contains ( & wildcard_component) {
748
- component = wildcard_component;
749
- } else {
750
- return Err ( ErrorKind :: UnknownComponent (
751
- self . name . to_string ( ) ,
752
- component. description ( & manifest) ,
753
- self . get_component_suggestion ( & component, & manifest, true ) ,
754
- )
755
- . into ( ) ) ;
756
- }
757
- }
758
-
759
- let changes = Changes {
760
- explicit_add_components : vec ! [ ] ,
761
- remove_components : vec ! [ component] ,
762
- } ;
763
-
764
- manifestation. update (
765
- & manifest,
766
- changes,
767
- false ,
768
- & self . download_cfg ( ) ,
769
- & self . download_cfg ( ) . notify_handler ,
770
- & toolchain. manifest_name ( ) ,
771
- false ,
772
- ) ?;
773
-
774
- Ok ( ( ) )
775
- } else {
776
- Err ( ErrorKind :: ComponentsUnsupported ( self . name . to_string ( ) ) . into ( ) )
777
- }
778
- }
779
725
// Distributable and Custom. Installed only.
780
726
pub fn binary_file ( & self , name : & str ) -> PathBuf {
781
727
let mut path = self . path . clone ( ) ;
@@ -890,6 +836,62 @@ impl<'a> DistributableToolchain<'a> {
890
836
) )
891
837
}
892
838
839
+ // Installed only.
840
+ pub fn remove_component ( & self , mut component : Component ) -> Result < ( ) > {
841
+ // Overlapping code with get_manifest :/.
842
+ if !self . 0 . exists ( ) {
843
+ return Err ( ErrorKind :: ToolchainNotInstalled ( self . 0 . name . to_owned ( ) ) . into ( ) ) ;
844
+ }
845
+
846
+ let toolchain = & self . 0 . name ;
847
+ let toolchain = ToolchainDesc :: from_str ( toolchain)
848
+ . chain_err ( || ErrorKind :: ComponentsUnsupported ( self . 0 . name . to_string ( ) ) ) ?;
849
+
850
+ let prefix = InstallPrefix :: from ( self . 0 . path . to_owned ( ) ) ;
851
+ let manifestation = Manifestation :: open ( prefix, toolchain. target . clone ( ) ) ?;
852
+
853
+ if let Some ( manifest) = manifestation. load_manifest ( ) ? {
854
+ // Rename the component if necessary.
855
+ if let Some ( c) = manifest. rename_component ( & component) {
856
+ component = c;
857
+ }
858
+
859
+ let dist_config = manifestation. read_config ( ) ?. unwrap ( ) ;
860
+ if !dist_config. components . contains ( & component) {
861
+ let wildcard_component = component. wildcard ( ) ;
862
+ if dist_config. components . contains ( & wildcard_component) {
863
+ component = wildcard_component;
864
+ } else {
865
+ return Err ( ErrorKind :: UnknownComponent (
866
+ self . 0 . name . to_string ( ) ,
867
+ component. description ( & manifest) ,
868
+ self . 0 . get_component_suggestion ( & component, & manifest, true ) ,
869
+ )
870
+ . into ( ) ) ;
871
+ }
872
+ }
873
+
874
+ let changes = Changes {
875
+ explicit_add_components : vec ! [ ] ,
876
+ remove_components : vec ! [ component] ,
877
+ } ;
878
+
879
+ manifestation. update (
880
+ & manifest,
881
+ changes,
882
+ false ,
883
+ & self . 0 . download_cfg ( ) ,
884
+ & self . 0 . download_cfg ( ) . notify_handler ,
885
+ & toolchain. manifest_name ( ) ,
886
+ false ,
887
+ ) ?;
888
+
889
+ Ok ( ( ) )
890
+ } else {
891
+ Err ( ErrorKind :: ComponentsUnsupported ( self . 0 . name . to_string ( ) ) . into ( ) )
892
+ }
893
+ }
894
+
893
895
// Installed only.
894
896
pub fn show_version ( & self ) -> Result < Option < String > > {
895
897
match self . get_manifest ( ) ? {
0 commit comments