aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_proc_macro_srv/Cargo.toml1
-rw-r--r--crates/ra_proc_macro_srv/src/tests/utils.rs3
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs11
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs7
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/main.rs10
5 files changed, 21 insertions, 11 deletions
diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml
index bb3003278..582102945 100644
--- a/crates/ra_proc_macro_srv/Cargo.toml
+++ b/crates/ra_proc_macro_srv/Cargo.toml
@@ -22,3 +22,4 @@ cargo_metadata = "0.10.0"
22difference = "2.0.0" 22difference = "2.0.0"
23# used as proc macro test target 23# used as proc macro test target
24serde_derive = "1.0.106" 24serde_derive = "1.0.106"
25ra_toolchain = { path = "../ra_toolchain" }
diff --git a/crates/ra_proc_macro_srv/src/tests/utils.rs b/crates/ra_proc_macro_srv/src/tests/utils.rs
index 84348b5de..8d85f2d8a 100644
--- a/crates/ra_proc_macro_srv/src/tests/utils.rs
+++ b/crates/ra_proc_macro_srv/src/tests/utils.rs
@@ -2,7 +2,6 @@
2 2
3use crate::dylib; 3use crate::dylib;
4use crate::ProcMacroSrv; 4use crate::ProcMacroSrv;
5pub use difference::Changeset as __Changeset;
6use ra_proc_macro::ListMacrosTask; 5use ra_proc_macro::ListMacrosTask;
7use std::str::FromStr; 6use std::str::FromStr;
8use test_utils::assert_eq_text; 7use test_utils::assert_eq_text;
@@ -13,7 +12,7 @@ mod fixtures {
13 12
14 // Use current project metadata to get the proc-macro dylib path 13 // Use current project metadata to get the proc-macro dylib path
15 pub fn dylib_path(crate_name: &str, version: &str) -> std::path::PathBuf { 14 pub fn dylib_path(crate_name: &str, version: &str) -> std::path::PathBuf {
16 let command = Command::new("cargo") 15 let command = Command::new(ra_toolchain::cargo())
17 .args(&["check", "--message-format", "json"]) 16 .args(&["check", "--message-format", "json"])
18 .output() 17 .output()
19 .unwrap() 18 .unwrap()
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs
index acb1dacb6..173c23b9e 100644
--- a/crates/rust-analyzer/src/lsp_ext.rs
+++ b/crates/rust-analyzer/src/lsp_ext.rs
@@ -121,12 +121,21 @@ pub struct RunnablesParams {
121 pub position: Option<Position>, 121 pub position: Option<Position>,
122} 122}
123 123
124// Must strictly correspond to the executable name
125#[derive(Serialize, Deserialize, Debug)]
126#[serde(rename_all = "lowercase")]
127pub enum RunnableKind {
128 Cargo,
129 Rustc,
130 Rustup,
131}
132
124#[derive(Deserialize, Serialize, Debug)] 133#[derive(Deserialize, Serialize, Debug)]
125#[serde(rename_all = "camelCase")] 134#[serde(rename_all = "camelCase")]
126pub struct Runnable { 135pub struct Runnable {
127 pub range: Range, 136 pub range: Range,
128 pub label: String, 137 pub label: String,
129 pub bin: String, 138 pub kind: RunnableKind,
130 pub args: Vec<String>, 139 pub args: Vec<String>,
131 pub extra_args: Vec<String>, 140 pub extra_args: Vec<String>,
132 pub env: FxHashMap<String, String>, 141 pub env: FxHashMap<String, String>,
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index 1f910ff82..bc7c7f1ef 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -426,7 +426,7 @@ pub fn handle_runnables(
426 res.push(lsp_ext::Runnable { 426 res.push(lsp_ext::Runnable {
427 range: Default::default(), 427 range: Default::default(),
428 label: format!("cargo {} -p {}", cmd, spec.package), 428 label: format!("cargo {} -p {}", cmd, spec.package),
429 bin: "cargo".to_string(), 429 kind: lsp_ext::RunnableKind::Cargo,
430 args: vec![cmd.to_string(), "--package".to_string(), spec.package.clone()], 430 args: vec![cmd.to_string(), "--package".to_string(), spec.package.clone()],
431 extra_args: Vec::new(), 431 extra_args: Vec::new(),
432 env: FxHashMap::default(), 432 env: FxHashMap::default(),
@@ -438,7 +438,7 @@ pub fn handle_runnables(
438 res.push(lsp_ext::Runnable { 438 res.push(lsp_ext::Runnable {
439 range: Default::default(), 439 range: Default::default(),
440 label: "cargo check --workspace".to_string(), 440 label: "cargo check --workspace".to_string(),
441 bin: "cargo".to_string(), 441 kind: lsp_ext::RunnableKind::Cargo,
442 args: vec!["check".to_string(), "--workspace".to_string()], 442 args: vec!["check".to_string(), "--workspace".to_string()],
443 extra_args: Vec::new(), 443 extra_args: Vec::new(),
444 env: FxHashMap::default(), 444 env: FxHashMap::default(),
@@ -982,10 +982,11 @@ fn to_lsp_runnable(
982 target.map_or_else(|| "run binary".to_string(), |t| format!("run {}", t)) 982 target.map_or_else(|| "run binary".to_string(), |t| format!("run {}", t))
983 } 983 }
984 }; 984 };
985
985 Ok(lsp_ext::Runnable { 986 Ok(lsp_ext::Runnable {
986 range: to_proto::range(&line_index, runnable.range), 987 range: to_proto::range(&line_index, runnable.range),
987 label, 988 label,
988 bin: "cargo".to_string(), 989 kind: lsp_ext::RunnableKind::Cargo,
989 args, 990 args,
990 extra_args, 991 extra_args,
991 env: { 992 env: {
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs
index 405ddb362..8b473ff74 100644
--- a/crates/rust-analyzer/tests/heavy_tests/main.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/main.rs
@@ -79,7 +79,7 @@ fn foo() {
79 { 79 {
80 "args": [ "test" ], 80 "args": [ "test" ],
81 "extraArgs": [ "foo", "--nocapture" ], 81 "extraArgs": [ "foo", "--nocapture" ],
82 "bin": "cargo", 82 "kind": "cargo",
83 "env": { "RUST_BACKTRACE": "short" }, 83 "env": { "RUST_BACKTRACE": "short" },
84 "cwd": null, 84 "cwd": null,
85 "label": "test foo", 85 "label": "test foo",
@@ -91,7 +91,7 @@ fn foo() {
91 { 91 {
92 "args": ["check", "--workspace"], 92 "args": ["check", "--workspace"],
93 "extraArgs": [], 93 "extraArgs": [],
94 "bin": "cargo", 94 "kind": "cargo",
95 "env": {}, 95 "env": {},
96 "cwd": null, 96 "cwd": null,
97 "label": "cargo check --workspace", 97 "label": "cargo check --workspace",
@@ -141,7 +141,7 @@ fn main() {}
141 { 141 {
142 "args": [ "test", "--package", "foo", "--test", "spam" ], 142 "args": [ "test", "--package", "foo", "--test", "spam" ],
143 "extraArgs": [ "test_eggs", "--exact", "--nocapture" ], 143 "extraArgs": [ "test_eggs", "--exact", "--nocapture" ],
144 "bin": "cargo", 144 "kind": "cargo",
145 "env": { "RUST_BACKTRACE": "short" }, 145 "env": { "RUST_BACKTRACE": "short" },
146 "label": "test test_eggs", 146 "label": "test test_eggs",
147 "range": { 147 "range": {
@@ -153,7 +153,7 @@ fn main() {}
153 { 153 {
154 "args": [ "check", "--package", "foo" ], 154 "args": [ "check", "--package", "foo" ],
155 "extraArgs": [], 155 "extraArgs": [],
156 "bin": "cargo", 156 "kind": "cargo",
157 "env": {}, 157 "env": {},
158 "label": "cargo check -p foo", 158 "label": "cargo check -p foo",
159 "range": { 159 "range": {
@@ -165,7 +165,7 @@ fn main() {}
165 { 165 {
166 "args": [ "test", "--package", "foo" ], 166 "args": [ "test", "--package", "foo" ],
167 "extraArgs": [], 167 "extraArgs": [],
168 "bin": "cargo", 168 "kind": "cargo",
169 "env": {}, 169 "env": {},
170 "label": "cargo test -p foo", 170 "label": "cargo test -p foo",
171 "range": { 171 "range": {