mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
add working dir to cargo metadata fail messages
This commit is contained in:
parent
53e2cdf18e
commit
27a0fd23d8
1 changed files with 17 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
//! FIXME: write short doc here
|
//! FIXME: write short doc here
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
convert::TryInto,
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
ops,
|
ops,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
@ -196,8 +197,23 @@ impl CargoWorkspace {
|
||||||
if let Some(target) = target {
|
if let Some(target) = target {
|
||||||
meta.other_options(vec![String::from("--filter-platform"), target]);
|
meta.other_options(vec![String::from("--filter-platform"), target]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut meta = meta.exec().with_context(|| {
|
let mut meta = meta.exec().with_context(|| {
|
||||||
format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display())
|
let cwd: Option<AbsPathBuf> =
|
||||||
|
std::env::current_dir().ok().and_then(|p| p.try_into().ok());
|
||||||
|
|
||||||
|
let workdir = cargo_toml
|
||||||
|
.parent()
|
||||||
|
.map(|p| p.to_path_buf())
|
||||||
|
.or(cwd)
|
||||||
|
.map(|dir| dir.to_string_lossy().to_string())
|
||||||
|
.unwrap_or_else(|| "<failed to get path>".into());
|
||||||
|
|
||||||
|
format!(
|
||||||
|
"Failed to run `cargo metadata --manifest-path {}` in `{}`",
|
||||||
|
cargo_toml.display(),
|
||||||
|
workdir
|
||||||
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let mut out_dir_by_id = FxHashMap::default();
|
let mut out_dir_by_id = FxHashMap::default();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue