@@ -2,18 +2,17 @@ import * as vscode from "vscode";
22import * as toolchain from "./toolchain" ;
33import type { Config } from "./config" ;
44import { log } from "./util" ;
5- import { unwrapUndefinable } from "./undefinable" ;
65
76// This ends up as the `type` key in tasks.json. RLS also uses `cargo` and
87// our configuration should be compatible with it so use the same key.
98export const TASK_TYPE = "cargo" ;
109export const TASK_SOURCE = "rust" ;
1110
1211export interface RustTargetDefinition extends vscode . TaskDefinition {
12+ program : string ;
1313 args : string [ ] ;
1414 cwd ?: string ;
1515 env ?: { [ key : string ] : string } ;
16- overrideCargo ?: string ;
1716}
1817
1918class RustTaskProvider implements vscode . TaskProvider {
@@ -38,12 +37,14 @@ class RustTaskProvider implements vscode.TaskProvider {
3837 { command : "run" , group : undefined } ,
3938 ] ;
4039
40+ const cargoPath = await toolchain . cargoPath ( ) ;
41+
4142 const tasks : vscode . Task [ ] = [ ] ;
4243 for ( const workspaceTarget of vscode . workspace . workspaceFolders || [ ] ) {
4344 for ( const def of defs ) {
4445 const vscodeTask = await buildRustTask (
4546 workspaceTarget ,
46- { type : TASK_TYPE , args : [ def . command ] } ,
47+ { type : TASK_TYPE , program : cargoPath , args : [ def . command ] } ,
4748 `cargo ${ def . command } ` ,
4849 this . config . problemMatcher ,
4950 this . config . cargoRunner ,
@@ -113,16 +114,7 @@ export async function buildRustTask(
113114 }
114115
115116 if ( ! exec ) {
116- // Check whether we must use a user-defined substitute for cargo.
117- // Split on spaces to allow overrides like "wrapper cargo".
118- const overrideCargo = definition . overrideCargo ?? definition . overrideCargo ;
119- const cargoPath = await toolchain . cargoPath ( ) ;
120- const cargoCommand = overrideCargo ?. split ( " " ) ?? [ cargoPath ] ;
121-
122- const fullCommand = [ ...cargoCommand , ...definition . args ] ;
123-
124- const processName = unwrapUndefinable ( fullCommand [ 0 ] ) ;
125- exec = new vscode . ProcessExecution ( processName , fullCommand . slice ( 1 ) , definition ) ;
117+ exec = new vscode . ProcessExecution ( definition . program , definition . args , definition ) ;
126118 }
127119
128120 return new vscode . Task (
0 commit comments