From 632b0f290232913ef9950ee46917d5c195193102 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sat, 26 Jan 2019 20:16:15 +0000 Subject: Use the correct working directory for cargo metadata and rustfmt --- crates/ra_lsp_server/src/project_model/cargo_workspace.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'crates/ra_lsp_server/src/project_model') diff --git a/crates/ra_lsp_server/src/project_model/cargo_workspace.rs b/crates/ra_lsp_server/src/project_model/cargo_workspace.rs index 75ae78bca..8cf99d586 100644 --- a/crates/ra_lsp_server/src/project_model/cargo_workspace.rs +++ b/crates/ra_lsp_server/src/project_model/cargo_workspace.rs @@ -117,9 +117,13 @@ impl Target { impl CargoWorkspace { pub fn from_cargo_metadata(cargo_toml: &Path) -> Result { - let meta = MetadataCommand::new() - .manifest_path(cargo_toml) - .features(CargoOpt::AllFeatures) + let mut meta = MetadataCommand::new(); + meta.manifest_path(cargo_toml) + .features(CargoOpt::AllFeatures); + if let Some(parent) = cargo_toml.parent() { + meta.current_dir(parent); + } + let meta = meta .exec() .map_err(|e| format_err!("cargo metadata failed: {}", e))?; let mut pkg_by_id = FxHashMap::default(); -- cgit v1.2.3