Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Unreleased

* Accept rustup toolchain shorthands in `rust-client.channel`, e.g. `stable-gnu` or `nightly-x86_64-msvc`
* Remove deprecated `rust-client.useWsl` setting (use the official
[Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension instead)

Expand Down
16 changes: 13 additions & 3 deletions src/rustup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,20 @@ export async function checkForRls(config: RustupConfig) {
}
}

async function hasToolchain(config: RustupConfig): Promise<boolean> {
async function hasToolchain({ channel, path }: RustupConfig): Promise<boolean> {
// In addition to a regular channel name, also handle shorthands e.g.
// `stable-msvc` or `stable-x86_64-msvc` but not `stable-x86_64-pc-msvc`.
const abiSuffix = ['-gnu', '-msvc'].find(abi => channel.endsWith(abi));
const [prefix, suffix] =
abiSuffix && channel.split('-').length <= 3
? [channel.substr(0, channel.length - abiSuffix.length), abiSuffix]
: [channel, undefined];
// Skip middle target triple components such as vendor as necessary, since
// `rustup` output lists toolchains with a full target triple inside
const matcher = new RegExp([prefix, suffix && `.*${suffix}`].join(''));
try {
const { stdout } = await exec(`${config.path} toolchain list`);
return stdout.includes(config.channel);
const { stdout } = await exec(`${path} toolchain list`);
return matcher.test(stdout);
} catch (e) {
console.log(e);
window.showErrorMessage(
Expand Down