about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-06-13 15:34:29 +0000
committerbors <bors@rust-lang.org>2024-06-13 15:34:29 +0000
commit85e87fbf299a19c1f1f4b89d42316a40f05b3fc2 (patch)
tree7dd9ad800cbe24e0f80ca571b97b94ebdfb0a273
parent66ec9772b54ab19ef2e3b752247215325fe4a404 (diff)
parentc2843be1bb75a3aae409b7e4fb5f6379ecb6e3cd (diff)
downloadrust-85e87fbf299a19c1f1f4b89d42316a40f05b3fc2.tar.gz
rust-85e87fbf299a19c1f1f4b89d42316a40f05b3fc2.zip
Auto merge of #17407 - davidbarsky:david/fix-17402, r=Veykril
fix: avoid doubling cargo args in runnables

Fixes #17402.

Sorry about this—I think I missed up the rebase!
-rw-r--r--src/tools/rust-analyzer/editors/code/src/tasks.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/tools/rust-analyzer/editors/code/src/tasks.ts b/src/tools/rust-analyzer/editors/code/src/tasks.ts
index c28a919231b..c14f7a1175c 100644
--- a/src/tools/rust-analyzer/editors/code/src/tasks.ts
+++ b/src/tools/rust-analyzer/editors/code/src/tasks.ts
@@ -1,8 +1,7 @@
 import * as vscode from "vscode";
-import * as toolchain from "./toolchain";
 import type { Config } from "./config";
 import { log } from "./util";
-import { unwrapUndefinable } from "./undefinable";
+import { expectNotUndefined, unwrapUndefinable } from "./undefinable";
 
 // This ends up as the `type` key in tasks.json. RLS also uses `cargo` and
 // our configuration should be compatible with it so use the same key.
@@ -142,14 +141,16 @@ async function cargoToExecution(
     if (definition.type === TASK_TYPE) {
         // Check whether we must use a user-defined substitute for cargo.
         // Split on spaces to allow overrides like "wrapper cargo".
-        const cargoPath = await toolchain.cargoPath();
-        const cargoCommand = definition.overrideCargo?.split(" ") ?? [cargoPath];
+        const cargoCommand = definition.overrideCargo?.split(" ") ?? [definition.command];
 
-        const args = [definition.command].concat(definition.args ?? []);
-        const fullCommand = [...cargoCommand, ...args];
-        const processName = unwrapUndefinable(fullCommand[0]);
+        const definitionArgs = expectNotUndefined(
+            definition.args,
+            "args were not provided via runnables; this is a bug.",
+        );
+        const args = [...cargoCommand.slice(1), ...definitionArgs];
+        const processName = unwrapUndefinable(cargoCommand[0]);
 
-        return new vscode.ProcessExecution(processName, fullCommand.slice(1), {
+        return new vscode.ProcessExecution(processName, args, {
             cwd: definition.cwd,
             env: definition.env,
         });