aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-27 00:31:42 +0100
committerGitHub <[email protected]>2020-06-27 00:31:42 +0100
commitb1a4e810a4909c36eabf6f4b746a021c2074c2c3 (patch)
tree88ddac56c779586cf9c678588fdd69970585f372
parent2dcab133e116ef691d45a32ab5eef8ae9cfa9477 (diff)
parent9617bb4f07f724b25abd4040a960f5ccff97b569 (diff)
Merge #5087
5087: Try to find rustfmt in more places r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--Cargo.lock1
-rw-r--r--crates/ra_toolchain/src/lib.rs4
-rw-r--r--crates/rust-analyzer/Cargo.toml1
-rw-r--r--crates/rust-analyzer/src/handlers.rs2
4 files changed, 7 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b2b624212..044314a8f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1395,6 +1395,7 @@ dependencies = [
1395 "ra_project_model", 1395 "ra_project_model",
1396 "ra_syntax", 1396 "ra_syntax",
1397 "ra_text_edit", 1397 "ra_text_edit",
1398 "ra_toolchain",
1398 "ra_tt", 1399 "ra_tt",
1399 "rand", 1400 "rand",
1400 "rustc-hash", 1401 "rustc-hash",
diff --git a/crates/ra_toolchain/src/lib.rs b/crates/ra_toolchain/src/lib.rs
index 3d2865e09..9532fb255 100644
--- a/crates/ra_toolchain/src/lib.rs
+++ b/crates/ra_toolchain/src/lib.rs
@@ -15,6 +15,10 @@ pub fn rustup() -> PathBuf {
15 get_path_for_executable("rustup") 15 get_path_for_executable("rustup")
16} 16}
17 17
18pub fn rustfmt() -> PathBuf {
19 get_path_for_executable("rustfmt")
20}
21
18/// Return a `PathBuf` to use for the given executable. 22/// Return a `PathBuf` to use for the given executable.
19/// 23///
20/// E.g., `get_path_for_executable("cargo")` may return just `cargo` if that 24/// E.g., `get_path_for_executable("cargo")` may return just `cargo` if that
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index 08c67ddd0..122a1605f 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -41,6 +41,7 @@ ra_text_edit = { path = "../ra_text_edit" }
41vfs = { path = "../vfs" } 41vfs = { path = "../vfs" }
42vfs-notify = { path = "../vfs-notify" } 42vfs-notify = { path = "../vfs-notify" }
43ra_cfg = { path = "../ra_cfg"} 43ra_cfg = { path = "../ra_cfg"}
44ra_toolchain = { path = "../ra_toolchain" }
44 45
45# This should only be used in CLI 46# This should only be used in CLI
46ra_db = { path = "../ra_db" } 47ra_db = { path = "../ra_db" }
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 6c21f25fe..38e3c3324 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -650,7 +650,7 @@ pub(crate) fn handle_formatting(
650 650
651 let mut rustfmt = match &snap.config.rustfmt { 651 let mut rustfmt = match &snap.config.rustfmt {
652 RustfmtConfig::Rustfmt { extra_args } => { 652 RustfmtConfig::Rustfmt { extra_args } => {
653 let mut cmd = process::Command::new("rustfmt"); 653 let mut cmd = process::Command::new(ra_toolchain::rustfmt());
654 cmd.args(extra_args); 654 cmd.args(extra_args);
655 if let Some(&crate_id) = crate_ids.first() { 655 if let Some(&crate_id) = crate_ids.first() {
656 // Assume all crates are in the same edition 656 // Assume all crates are in the same edition