removing unused code

This commit is contained in:
Bruno Ortiz 2023-04-02 22:06:15 -03:00
parent 299382dacd
commit fc57339fdf

View file

@ -3,9 +3,7 @@ import * as os from "os";
import * as path from "path";
import * as readline from "readline";
import * as vscode from "vscode";
import { execute, log, memoizeAsync } from "./util";
const TOOLCHAIN_PATTERN = new RegExp(/(.*)\s\(.*\)/);
import {execute, log, memoizeAsync} from "./util";
interface CompilationArtifact {
fileName: string;
@ -24,7 +22,7 @@ export class Cargo {
readonly rootFolder: string,
readonly output: vscode.OutputChannel,
readonly env: Record<string, string>
) { }
) {}
// Made public for testing purposes
static artifactSpec(args: readonly string[]): ArtifactSpec {
@ -44,7 +42,7 @@ export class Cargo {
}
}
const result: ArtifactSpec = { cargoArgs: cargoArgs };
const result: ArtifactSpec = {cargoArgs: cargoArgs};
if (cargoArgs[0] === "test" || cargoArgs[0] === "bench") {
// for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests
// produce 2 artifacts: {"kind": "bin"} and {"kind": "test"}
@ -149,7 +147,7 @@ export class Cargo {
cargo.stderr.on("data", (chunk) => onStderrString(chunk.toString()));
const rl = readline.createInterface({ input: cargo.stdout });
const rl = readline.createInterface({input: cargo.stdout});
rl.on("line", (line) => {
const message = JSON.parse(line);
onStdoutJson(message);
@ -191,14 +189,14 @@ export async function getSysroot(dir: string): Promise<string> {
const rustcPath = await getPathForExecutable("rustc");
// do not memoize the result because the toolchain may change between runs
return await execute(`${rustcPath} --print sysroot`, { cwd: dir });
return await execute(`${rustcPath} --print sysroot`, {cwd: dir});
}
export async function getRustcId(dir: string): Promise<string> {
const rustcPath = await getPathForExecutable("rustc");
// do not memoize the result because the toolchain may change between runs
const data = await execute(`${rustcPath} -V -v`, { cwd: dir });
const data = await execute(`${rustcPath} -V -v`, {cwd: dir});
const rx = /commit-hash:\s(.*)$/m;
return rx.exec(data)![1];
@ -219,11 +217,6 @@ export function cargoPath(): Promise<string> {
return getPathForExecutable("cargo");
}
/** Mirrors `toolchain::cargo()` implementation */
export function rustupPath(): Promise<string> {
return getPathForExecutable("rustup");
}
/** Mirrors `toolchain::get_path_for_executable()` implementation */
export const getPathForExecutable = memoizeAsync(
// We apply caching to decrease file-system interactions