This repository was archived by the owner on Nov 18, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 11### Unreleased
22
3+ * Accept rustup toolchain shorthands in ` rust-client.channel ` , e.g. ` stable-gnu ` or ` nightly-x86_64-msvc `
34* Remove deprecated ` rust-client.useWsl ` setting (use the official
45[ Remote - WSL] ( https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl ) extension instead)
56
Original file line number Diff line number Diff line change @@ -81,10 +81,20 @@ export async function checkForRls(config: RustupConfig) {
8181 }
8282}
8383
84- async function hasToolchain ( config : RustupConfig ) : Promise < boolean > {
84+ async function hasToolchain ( { channel, path } : RustupConfig ) : Promise < boolean > {
85+ // In addition to a regular channel name, also handle shorthands e.g.
86+ // `stable-msvc` or `stable-x86_64-msvc` but not `stable-x86_64-pc-msvc`.
87+ const abiSuffix = [ '-gnu' , '-msvc' ] . find ( abi => channel . endsWith ( abi ) ) ;
88+ const [ prefix , suffix ] =
89+ abiSuffix && channel . split ( '-' ) . length <= 3
90+ ? [ channel . substr ( 0 , channel . length - abiSuffix . length ) , abiSuffix ]
91+ : [ channel , undefined ] ;
92+ // Skip middle target triple components such as vendor as necessary, since
93+ // `rustup` output lists toolchains with a full target triple inside
94+ const matcher = new RegExp ( [ prefix , suffix && `.*${ suffix } ` ] . join ( '' ) ) ;
8595 try {
86- const { stdout } = await exec ( `${ config . path } toolchain list` ) ;
87- return stdout . includes ( config . channel ) ;
96+ const { stdout } = await exec ( `${ path } toolchain list` ) ;
97+ return matcher . test ( stdout ) ;
8898 } catch ( e ) {
8999 console . log ( e ) ;
90100 window . showErrorMessage (
You can’t perform that action at this time.
0 commit comments