@@ -315,23 +315,48 @@ impl Toolchain {
315
315
RustupAction :: Remove => ( "remove" , "removing" ) ,
316
316
} ;
317
317
318
- let thing = thing . to_string ( ) ;
319
- let action = action . to_string ( ) ;
318
+ let toolchain_name = self . rustup_name ( ) ;
319
+ info ! ( "{log_action_ing} {thing} {name} for toolchain {toolchain_name}" ) ;
320
320
321
321
#[ cfg( feature = "unstable-toolchain-ci" ) ]
322
- if let ToolchainInner :: CI { .. } = self . inner {
323
- failure:: bail!(
324
- "{} {} on CI toolchains is not supported yet" ,
325
- log_action_ing,
326
- thing
327
- ) ;
322
+ if let ToolchainInner :: CI ( ci) = & self . inner {
323
+ if let RustupAction :: Remove = action {
324
+ failure:: bail!( "removing {thing} on CI toolchains is not supported yet" ) ;
325
+ }
326
+
327
+ let mut args = Vec :: with_capacity ( 6 ) ;
328
+ if ci. alt {
329
+ args. push ( "--alt" ) ;
330
+ }
331
+ args. extend ( [
332
+ // `-f` is required otherwise rustup-toolchain-install-master will early return
333
+ // because the toolchain (but not the new component) is already installed.
334
+ "-f" ,
335
+ match thing {
336
+ RustupThing :: Target => "--targets" ,
337
+ RustupThing :: Component => "--component" ,
338
+ } ,
339
+ name,
340
+ // We have to pass `--` otherwise the sha is interpreted as a target name.
341
+ "--" ,
342
+ & ci. sha ,
343
+ ] ) ;
344
+
345
+ Command :: new ( workspace, & RUSTUP_TOOLCHAIN_INSTALL_MASTER )
346
+ . args ( & args)
347
+ . run ( )
348
+ . with_context ( |_| {
349
+ format ! (
350
+ "unable to {log_action} {thing} {name} for CI toolchain {toolchain_name} \
351
+ via rustup-toolchain-install-master"
352
+ )
353
+ } ) ?;
354
+
355
+ return Ok ( ( ) ) ;
328
356
}
329
357
330
- let toolchain_name = self . rustup_name ( ) ;
331
- info ! (
332
- "{} {} {} for toolchain {}" ,
333
- log_action_ing, thing, name, toolchain_name
334
- ) ;
358
+ let thing = thing. to_string ( ) ;
359
+ let action = action. to_string ( ) ;
335
360
336
361
Command :: new ( workspace, & RUSTUP )
337
362
. args ( & [
@@ -344,8 +369,7 @@ impl Toolchain {
344
369
. run ( )
345
370
. with_context ( |_| {
346
371
format ! (
347
- "unable to {} {} {} for toolchain {} via rustup" ,
348
- log_action, thing, name, toolchain_name,
372
+ "unable to {log_action} {thing} {name} for toolchain {toolchain_name} via rustup"
349
373
)
350
374
} ) ?;
351
375
Ok ( ( ) )
@@ -517,7 +541,7 @@ pub(crate) fn list_installed_toolchains(rustup_home: &Path) -> Result<Vec<Toolch
517
541
#[ cfg( feature = "unstable-toolchain-ci" ) ]
518
542
{
519
543
let ( sha, alt) = if name. ends_with ( "-alt" ) {
520
- ( ( & name[ ..name. len ( ) - 4 ] ) . to_string ( ) , true )
544
+ ( ( name[ ..name. len ( ) - 4 ] ) . to_string ( ) , true )
521
545
} else {
522
546
( name, false )
523
547
} ;
0 commit comments