@@ -228,9 +228,19 @@ fn run() -> Result<ExitStatus> {
228228                . unwrap_or_else ( || Target :: from ( host. triple ( ) ,  & target_list) ) ; 
229229            let  toml = toml ( & root) ?; 
230230
231-             let  sysroot = rustc:: sysroot ( & host,  & target,  verbose) ?; 
232-             let  toolchain  = sysroot. file_name ( ) . and_then ( |file_name| file_name. to_str ( ) ) 
231+             let  mut   sysroot = rustc:: sysroot ( & host,  & target,  verbose) ?; 
232+             let  default_toolchain  = sysroot. file_name ( ) . and_then ( |file_name| file_name. to_str ( ) ) 
233233                . ok_or ( "couldn't get toolchain name" ) ?; 
234+             let  toolchain = if  let  Some ( channel)  = args. channel  { 
235+                 [ channel] . iter ( ) . map ( |c| c. as_str ( ) ) . chain ( 
236+                     default_toolchain. splitn ( 2 ,  '-' ) . skip ( 1 ) 
237+                 ) 
238+                     . collect :: < Vec < _ > > ( ) 
239+                     . join ( "-" ) 
240+             }  else  { 
241+                 default_toolchain. to_string ( ) 
242+             } ; 
243+             sysroot. set_file_name ( & toolchain) ; 
234244
235245            let  installed_toolchains = rustup:: installed_toolchains ( verbose) ?; 
236246
@@ -250,13 +260,13 @@ fn run() -> Result<ExitStatus> {
250260
251261            if  !uses_xargo && !available_targets. is_installed ( & target)  { 
252262                rustup:: install ( & target,  & toolchain,  verbose) ?; 
253-             }  else  if  !rustup:: component_is_installed ( "rust-src" ,  toolchain,  verbose) ? { 
254-                 rustup:: install_component ( "rust-src" ,  toolchain,  verbose) ?; 
263+             }  else  if  !rustup:: component_is_installed ( "rust-src" ,  & toolchain,  verbose) ? { 
264+                 rustup:: install_component ( "rust-src" ,  & toolchain,  verbose) ?; 
255265            } 
256266
257267            if  args. subcommand . map ( |sc| sc == Subcommand :: Clippy ) . unwrap_or ( false )  &&
258-                 !rustup:: component_is_installed ( "clippy" ,  toolchain,  verbose) ? { 
259-                 rustup:: install_component ( "clippy" ,  toolchain,  verbose) ?; 
268+                 !rustup:: component_is_installed ( "clippy" ,  & toolchain,  verbose) ? { 
269+                 rustup:: install_component ( "clippy" ,  & toolchain,  verbose) ?; 
260270            } 
261271
262272            let  needs_interpreter = args. subcommand . map ( |sc| sc. needs_interpreter ( ) ) . unwrap_or ( false ) ; 
0 commit comments