aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src/cargo_workspace.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_project_model/src/cargo_workspace.rs')
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs14
1 files changed, 3 insertions, 11 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index 16fff9f1c..eb9f33ee8 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -1,7 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use std::{ 3use std::{
4 env,
5 ffi::OsStr, 4 ffi::OsStr,
6 ops, 5 ops,
7 path::{Path, PathBuf}, 6 path::{Path, PathBuf},
@@ -12,6 +11,7 @@ use anyhow::{Context, Result};
12use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; 11use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId};
13use ra_arena::{Arena, Idx}; 12use ra_arena::{Arena, Idx};
14use ra_db::Edition; 13use ra_db::Edition;
14use ra_env::get_path_for_executable;
15use rustc_hash::FxHashMap; 15use rustc_hash::FxHashMap;
16 16
17/// `CargoWorkspace` represents the logical structure of, well, a Cargo 17/// `CargoWorkspace` represents the logical structure of, well, a Cargo
@@ -146,12 +146,8 @@ impl CargoWorkspace {
146 cargo_toml: &Path, 146 cargo_toml: &Path,
147 cargo_features: &CargoConfig, 147 cargo_features: &CargoConfig,
148 ) -> Result<CargoWorkspace> { 148 ) -> Result<CargoWorkspace> {
149 let _ = Command::new(cargo_binary())
150 .arg("--version")
151 .output()
152 .context("failed to run `cargo --version`, is `cargo` in PATH?")?;
153
154 let mut meta = MetadataCommand::new(); 149 let mut meta = MetadataCommand::new();
150 meta.cargo_path(get_path_for_executable("cargo")?);
155 meta.manifest_path(cargo_toml); 151 meta.manifest_path(cargo_toml);
156 if cargo_features.all_features { 152 if cargo_features.all_features {
157 meta.features(CargoOpt::AllFeatures); 153 meta.features(CargoOpt::AllFeatures);
@@ -293,7 +289,7 @@ pub fn load_extern_resources(
293 cargo_toml: &Path, 289 cargo_toml: &Path,
294 cargo_features: &CargoConfig, 290 cargo_features: &CargoConfig,
295) -> Result<ExternResources> { 291) -> Result<ExternResources> {
296 let mut cmd = Command::new(cargo_binary()); 292 let mut cmd = Command::new(get_path_for_executable("cargo")?);
297 cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); 293 cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml);
298 if cargo_features.all_features { 294 if cargo_features.all_features {
299 cmd.arg("--all-features"); 295 cmd.arg("--all-features");
@@ -347,7 +343,3 @@ fn is_dylib(path: &Path) -> bool {
347 Some(ext) => matches!(ext.as_str(), "dll" | "dylib" | "so"), 343 Some(ext) => matches!(ext.as_str(), "dll" | "dylib" | "so"),
348 } 344 }
349} 345}
350
351fn cargo_binary() -> String {
352 env::var("CARGO").unwrap_or_else(|_| "cargo".to_string())
353}