@@ -2,18 +2,17 @@ import * as vscode from "vscode";
2
2
import * as toolchain from "./toolchain" ;
3
3
import type { Config } from "./config" ;
4
4
import { log } from "./util" ;
5
- import { unwrapUndefinable } from "./undefinable" ;
6
5
7
6
// This ends up as the `type` key in tasks.json. RLS also uses `cargo` and
8
7
// our configuration should be compatible with it so use the same key.
9
8
export const TASK_TYPE = "cargo" ;
10
9
export const TASK_SOURCE = "rust" ;
11
10
12
11
export interface RustTargetDefinition extends vscode . TaskDefinition {
12
+ program : string ;
13
13
args : string [ ] ;
14
14
cwd ?: string ;
15
15
env ?: { [ key : string ] : string } ;
16
- overrideCargo ?: string ;
17
16
}
18
17
19
18
class RustTaskProvider implements vscode . TaskProvider {
@@ -38,12 +37,14 @@ class RustTaskProvider implements vscode.TaskProvider {
38
37
{ command : "run" , group : undefined } ,
39
38
] ;
40
39
40
+ const cargoPath = await toolchain . cargoPath ( ) ;
41
+
41
42
const tasks : vscode . Task [ ] = [ ] ;
42
43
for ( const workspaceTarget of vscode . workspace . workspaceFolders || [ ] ) {
43
44
for ( const def of defs ) {
44
45
const vscodeTask = await buildRustTask (
45
46
workspaceTarget ,
46
- { type : TASK_TYPE , args : [ def . command ] } ,
47
+ { type : TASK_TYPE , program : cargoPath , args : [ def . command ] } ,
47
48
`cargo ${ def . command } ` ,
48
49
this . config . problemMatcher ,
49
50
this . config . cargoRunner ,
@@ -113,16 +114,7 @@ export async function buildRustTask(
113
114
}
114
115
115
116
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 ) ;
126
118
}
127
119
128
120
return new vscode . Task (
0 commit comments