This repository was archived by the owner on Nov 18, 2022. It is now read-only.
File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 1
1
### Unreleased
2
2
3
+ * Accept rustup toolchain shorthands in ` rust-client.channel ` , e.g. ` stable-gnu ` or ` nightly-x86_64-msvc `
3
4
* Remove deprecated ` rust-client.useWsl ` setting (use the official
4
5
[ Remote - WSL] ( https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl ) extension instead)
5
6
Original file line number Diff line number Diff line change @@ -81,10 +81,20 @@ export async function checkForRls(config: RustupConfig) {
81
81
}
82
82
}
83
83
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 ( '' ) ) ;
85
95
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 ) ;
88
98
} catch ( e ) {
89
99
console . log ( e ) ;
90
100
window . showErrorMessage (
You can’t perform that action at this time.
0 commit comments