aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock4
-rw-r--r--crates/rust-analyzer/src/handlers.rs17
-rw-r--r--crates/syntax/Cargo.toml2
3 files changed, 20 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6e25d4f86..71223218d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1438,9 +1438,9 @@ dependencies = [
1438 1438
1439[[package]] 1439[[package]]
1440name = "rustc-ap-rustc_lexer" 1440name = "rustc-ap-rustc_lexer"
1441version = "697.0.0" 1441version = "700.0.0"
1442source = "registry+https://github.com/rust-lang/crates.io-index" 1442source = "registry+https://github.com/rust-lang/crates.io-index"
1443checksum = "67adbe260a0a11910624d6d28c0304fcf7b063e666682111005c83b09f73429d" 1443checksum = "5ed36784376b69c941d7aa36e960a52ac712e2663960357121a4d9f2cc58e225"
1444dependencies = [ 1444dependencies = [
1445 "unicode-xid", 1445 "unicode-xid",
1446] 1446]
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 001f3a37d..42451cd2d 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -858,6 +858,23 @@ pub(crate) fn handle_formatting(
858 RustfmtConfig::Rustfmt { extra_args } => { 858 RustfmtConfig::Rustfmt { extra_args } => {
859 let mut cmd = process::Command::new(toolchain::rustfmt()); 859 let mut cmd = process::Command::new(toolchain::rustfmt());
860 cmd.args(extra_args); 860 cmd.args(extra_args);
861 // try to chdir to the file so we can respect `rustfmt.toml`
862 // FIXME: use `rustfmt --config-path` once
863 // https://github.com/rust-lang/rustfmt/issues/4660 gets fixed
864 match params.text_document.uri.to_file_path() {
865 Ok(mut path) => {
866 // pop off file name
867 if path.pop() && path.is_dir() {
868 cmd.current_dir(path);
869 }
870 }
871 Err(_) => {
872 log::error!(
873 "Unable to get file path for {}, rustfmt.toml might be ignored",
874 params.text_document.uri
875 );
876 }
877 }
861 if let Some(&crate_id) = crate_ids.first() { 878 if let Some(&crate_id) = crate_ids.first() {
862 // Assume all crates are in the same edition 879 // Assume all crates are in the same edition
863 let edition = snap.analysis.crate_edition(crate_id)?; 880 let edition = snap.analysis.crate_edition(crate_id)?;
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml
index 55b437a3a..24298fbfa 100644
--- a/crates/syntax/Cargo.toml
+++ b/crates/syntax/Cargo.toml
@@ -13,7 +13,7 @@ doctest = false
13[dependencies] 13[dependencies]
14itertools = "0.10.0" 14itertools = "0.10.0"
15rowan = "0.12" 15rowan = "0.12"
16rustc_lexer = { version = "697.0.0", package = "rustc-ap-rustc_lexer" } 16rustc_lexer = { version = "700.0.0", package = "rustc-ap-rustc_lexer" }
17rustc-hash = "1.1.0" 17rustc-hash = "1.1.0"
18arrayvec = "0.5.1" 18arrayvec = "0.5.1"
19once_cell = "1.3.1" 19once_cell = "1.3.1"