Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/toolchain.ts')
-rw-r--r--editors/code/src/toolchain.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts
index a48d2d90cc..6a0b5c26d8 100644
--- a/editors/code/src/toolchain.ts
+++ b/editors/code/src/toolchain.ts
@@ -4,6 +4,7 @@ import * as path from "path";
import * as readline from "readline";
import * as vscode from "vscode";
import { execute, log, memoizeAsync, unwrapNullable, unwrapUndefinable } from "./util";
+import type { CargoRunnableArgs } from "./lsp_ext";
interface CompilationArtifact {
fileName: string;
@@ -25,9 +26,8 @@ export class Cargo {
) {}
// Made public for testing purposes
- static artifactSpec(args: readonly string[]): ArtifactSpec {
- const cargoArgs = [...args, "--message-format=json"];
-
+ static artifactSpec(cargoArgs: string[], executableArgs?: string[]): ArtifactSpec {
+ cargoArgs = [...cargoArgs, "--message-format=json"];
// arguments for a runnable from the quick pick should be updated.
// see crates\rust-analyzer\src\main_loop\handlers.rs, handle_code_lens
switch (cargoArgs[0]) {
@@ -48,6 +48,9 @@ export class Cargo {
// produce 2 artifacts: {"kind": "bin"} and {"kind": "test"}
result.filter = (artifacts) => artifacts.filter((it) => it.isTest);
}
+ if (executableArgs) {
+ cargoArgs.push("--", ...executableArgs);
+ }
return result;
}
@@ -84,8 +87,10 @@ export class Cargo {
return spec.filter?.(artifacts) ?? artifacts;
}
- async executableFromArgs(args: readonly string[]): Promise<string> {
- const artifacts = await this.getArtifacts(Cargo.artifactSpec(args));
+ async executableFromArgs(runnableArgs: CargoRunnableArgs): Promise<string> {
+ const artifacts = await this.getArtifacts(
+ Cargo.artifactSpec(runnableArgs.cargoArgs, runnableArgs.executableArgs),
+ );
if (artifacts.length === 0) {
throw new Error("No compilation artifacts");