@@ -1172,8 +1172,9 @@ fn component_list(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
1172
1172
1173
1173
fn component_add ( cfg : & Cfg , m : & ArgMatches < ' _ > ) -> Result < ( ) > {
1174
1174
let toolchain = explicit_or_dir_toolchain ( cfg, m) ?;
1175
+ let distributable = DistributableToolchain :: new ( & toolchain) ?;
1175
1176
let target = m. value_of ( "target" ) . map ( TargetTriple :: new) . or_else ( || {
1176
- toolchain
1177
+ distributable
1177
1178
. desc ( )
1178
1179
. as_ref ( )
1179
1180
. ok ( )
@@ -1183,7 +1184,6 @@ fn component_add(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
1183
1184
for component in m. values_of ( "component" ) . unwrap ( ) {
1184
1185
let new_component = Component :: new_with_target ( component, false )
1185
1186
. unwrap_or_else ( || Component :: new ( component. to_string ( ) , target. clone ( ) , true ) ) ;
1186
- let distributable = DistributableToolchain :: new ( & toolchain) ?;
1187
1187
distributable. add_component ( new_component) ?;
1188
1188
}
1189
1189
@@ -1192,8 +1192,10 @@ fn component_add(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
1192
1192
1193
1193
fn component_remove ( cfg : & Cfg , m : & ArgMatches < ' _ > ) -> Result < ( ) > {
1194
1194
let toolchain = explicit_or_dir_toolchain ( cfg, m) ?;
1195
+ let distributable = DistributableToolchain :: new ( & toolchain)
1196
+ . chain_err ( || rustup:: ErrorKind :: ComponentsUnsupported ( toolchain. name ( ) . to_string ( ) ) ) ?;
1195
1197
let target = m. value_of ( "target" ) . map ( TargetTriple :: new) . or_else ( || {
1196
- toolchain
1198
+ distributable
1197
1199
. desc ( )
1198
1200
. as_ref ( )
1199
1201
. ok ( )
@@ -1203,9 +1205,6 @@ fn component_remove(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
1203
1205
for component in m. values_of ( "component" ) . unwrap ( ) {
1204
1206
let new_component = Component :: new_with_target ( component, false )
1205
1207
. unwrap_or_else ( || Component :: new ( component. to_string ( ) , target. clone ( ) , true ) ) ;
1206
-
1207
- let distributable = DistributableToolchain :: new ( & toolchain)
1208
- . chain_err ( || rustup:: ErrorKind :: ComponentsUnsupported ( toolchain. name ( ) . to_string ( ) ) ) ?;
1209
1208
distributable. remove_component ( new_component) ?;
1210
1209
}
1211
1210
0 commit comments