@@ -315,23 +315,48 @@ impl Toolchain {
315315 RustupAction :: Remove => ( "remove" , "removing" ) ,
316316 } ;
317317
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}" ) ;
320320
321321 #[ 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 ( ( ) ) ;
328356 }
329357
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 ( ) ;
335360
336361 Command :: new ( workspace, & RUSTUP )
337362 . args ( & [
@@ -344,8 +369,7 @@ impl Toolchain {
344369 . run ( )
345370 . with_context ( |_| {
346371 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"
349373 )
350374 } ) ?;
351375 Ok ( ( ) )
@@ -517,7 +541,7 @@ pub(crate) fn list_installed_toolchains(rustup_home: &Path) -> Result<Vec<Toolch
517541 #[ cfg( feature = "unstable-toolchain-ci" ) ]
518542 {
519543 let ( sha, alt) = if name. ends_with ( "-alt" ) {
520- ( ( & name[ ..name. len ( ) - 4 ] ) . to_string ( ) , true )
544+ ( ( name[ ..name. len ( ) - 4 ] ) . to_string ( ) , true )
521545 } else {
522546 ( name, false )
523547 } ;
0 commit comments