diff options
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop/handlers.rs | 8 | ||||
-rw-r--r-- | editors/code/src/cargo.ts | 4 | ||||
-rw-r--r-- | editors/code/src/tasks.ts | 7 |
5 files changed, 16 insertions, 5 deletions
diff --git a/Cargo.lock b/Cargo.lock index def4ed45e..7de784c1c 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -1364,6 +1364,7 @@ dependencies = [ | |||
1364 | "ra_syntax", | 1364 | "ra_syntax", |
1365 | "ra_text_edit", | 1365 | "ra_text_edit", |
1366 | "ra_tt", | 1366 | "ra_tt", |
1367 | "ra_toolchain", | ||
1367 | "ra_vfs", | 1368 | "ra_vfs", |
1368 | "rand", | 1369 | "rand", |
1369 | "relative-path", | 1370 | "relative-path", |
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 65b487db3..2e49448cc 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -48,6 +48,7 @@ hir = { path = "../ra_hir", package = "ra_hir" } | |||
48 | hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } | 48 | hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } |
49 | hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } | 49 | hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } |
50 | ra_proc_macro_srv = { path = "../ra_proc_macro_srv" } | 50 | ra_proc_macro_srv = { path = "../ra_proc_macro_srv" } |
51 | ra_toolchain = { path = "../ra_toolchain" } | ||
51 | 52 | ||
52 | [target.'cfg(windows)'.dependencies] | 53 | [target.'cfg(windows)'.dependencies] |
53 | winapi = "0.3.8" | 54 | winapi = "0.3.8" |
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index 1f910ff82..1b5b3325c 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs | |||
@@ -40,6 +40,7 @@ use crate::{ | |||
40 | world::WorldSnapshot, | 40 | world::WorldSnapshot, |
41 | LspError, Result, | 41 | LspError, Result, |
42 | }; | 42 | }; |
43 | use anyhow::Context; | ||
43 | 44 | ||
44 | pub fn handle_analyzer_status(world: WorldSnapshot, _: ()) -> Result<String> { | 45 | pub fn handle_analyzer_status(world: WorldSnapshot, _: ()) -> Result<String> { |
45 | let _p = profile("handle_analyzer_status"); | 46 | let _p = profile("handle_analyzer_status"); |
@@ -982,10 +983,15 @@ fn to_lsp_runnable( | |||
982 | target.map_or_else(|| "run binary".to_string(), |t| format!("run {}", t)) | 983 | target.map_or_else(|| "run binary".to_string(), |t| format!("run {}", t)) |
983 | } | 984 | } |
984 | }; | 985 | }; |
986 | let cargo_path = ra_toolchain::cargo() | ||
987 | .to_str() | ||
988 | .context("Path to cargo executable contains invalid UTF8 characters")? | ||
989 | .to_owned(); | ||
990 | |||
985 | Ok(lsp_ext::Runnable { | 991 | Ok(lsp_ext::Runnable { |
986 | range: to_proto::range(&line_index, runnable.range), | 992 | range: to_proto::range(&line_index, runnable.range), |
987 | label, | 993 | label, |
988 | bin: "cargo".to_string(), | 994 | bin: cargo_path, |
989 | args, | 995 | args, |
990 | extra_args, | 996 | extra_args, |
991 | env: { | 997 | env: { |
diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts index a55b2f860..46cd3d777 100644 --- a/editors/code/src/cargo.ts +++ b/editors/code/src/cargo.ts | |||
@@ -126,8 +126,8 @@ export class Cargo { | |||
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | // Mirrors `ra_env::get_path_for_executable` implementation | 129 | // Mirrors `ra_toolchain::cargo()` implementation |
130 | function getCargoPathOrFail(): string { | 130 | export function getCargoPathOrFail(): string { |
131 | const envVar = process.env.CARGO; | 131 | const envVar = process.env.CARGO; |
132 | const executableName = "cargo"; | 132 | const executableName = "cargo"; |
133 | 133 | ||
diff --git a/editors/code/src/tasks.ts b/editors/code/src/tasks.ts index 1366c76d6..c22d69362 100644 --- a/editors/code/src/tasks.ts +++ b/editors/code/src/tasks.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import * as vscode from 'vscode'; | 1 | import * as vscode from 'vscode'; |
2 | import { getCargoPathOrFail } from "./cargo"; | ||
2 | 3 | ||
3 | // This ends up as the `type` key in tasks.json. RLS also uses `cargo` and | 4 | // This ends up as the `type` key in tasks.json. RLS also uses `cargo` and |
4 | // our configuration should be compatible with it so use the same key. | 5 | // our configuration should be compatible with it so use the same key. |
@@ -24,6 +25,8 @@ class CargoTaskProvider implements vscode.TaskProvider { | |||
24 | // set of tasks that always exist. These tasks cannot be removed in | 25 | // set of tasks that always exist. These tasks cannot be removed in |
25 | // tasks.json - only tweaked. | 26 | // tasks.json - only tweaked. |
26 | 27 | ||
28 | const cargoPath = getCargoPathOrFail(); | ||
29 | |||
27 | return [ | 30 | return [ |
28 | { command: 'build', group: vscode.TaskGroup.Build }, | 31 | { command: 'build', group: vscode.TaskGroup.Build }, |
29 | { command: 'check', group: vscode.TaskGroup.Build }, | 32 | { command: 'check', group: vscode.TaskGroup.Build }, |
@@ -46,7 +49,7 @@ class CargoTaskProvider implements vscode.TaskProvider { | |||
46 | `cargo ${command}`, | 49 | `cargo ${command}`, |
47 | 'rust', | 50 | 'rust', |
48 | // What to do when this command is executed. | 51 | // What to do when this command is executed. |
49 | new vscode.ShellExecution('cargo', [command]), | 52 | new vscode.ShellExecution(cargoPath, [command]), |
50 | // Problem matchers. | 53 | // Problem matchers. |
51 | ['$rustc'], | 54 | ['$rustc'], |
52 | ); | 55 | ); |
@@ -80,4 +83,4 @@ class CargoTaskProvider implements vscode.TaskProvider { | |||
80 | export function activateTaskProvider(target: vscode.WorkspaceFolder): vscode.Disposable { | 83 | export function activateTaskProvider(target: vscode.WorkspaceFolder): vscode.Disposable { |
81 | const provider = new CargoTaskProvider(target); | 84 | const provider = new CargoTaskProvider(target); |
82 | return vscode.tasks.registerTaskProvider(TASK_TYPE, provider); | 85 | return vscode.tasks.registerTaskProvider(TASK_TYPE, provider); |
83 | } \ No newline at end of file | 86 | } |