fix: ensure that ws loading error includes path to ws
This commit is contained in:
parent
00b9d9faf4
commit
49318bbae7
@ -31,6 +31,7 @@
|
|||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
fmt,
|
||||||
fs::{self, read_dir, ReadDir},
|
fs::{self, read_dir, ReadDir},
|
||||||
io,
|
io,
|
||||||
process::Command,
|
process::Command,
|
||||||
@ -145,6 +146,16 @@ pub fn discover_all(paths: &[AbsPathBuf]) -> Vec<ProjectManifest> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ProjectManifest {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
ProjectManifest::ProjectJson(it) | ProjectManifest::CargoToml(it) => {
|
||||||
|
fmt::Display::fmt(&it, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn utf8_stdout(mut cmd: Command) -> Result<String> {
|
fn utf8_stdout(mut cmd: Command) -> Result<String> {
|
||||||
let output = cmd.output().with_context(|| format!("{cmd:?} failed"))?;
|
let output = cmd.output().with_context(|| format!("{cmd:?} failed"))?;
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//! See [`ManifestPath`].
|
//! See [`ManifestPath`].
|
||||||
use std::{ops, path::Path};
|
use std::{fmt, ops, path::Path};
|
||||||
|
|
||||||
use paths::{AbsPath, AbsPathBuf};
|
use paths::{AbsPath, AbsPathBuf};
|
||||||
|
|
||||||
@ -40,6 +40,12 @@ pub fn canonicalize(&self) -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ManifestPath {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
fmt::Display::fmt(&self.file.display(), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ops::Deref for ManifestPath {
|
impl ops::Deref for ManifestPath {
|
||||||
type Target = AbsPath;
|
type Target = AbsPath;
|
||||||
|
|
||||||
|
@ -151,6 +151,15 @@ pub fn load(
|
|||||||
manifest: ProjectManifest,
|
manifest: ProjectManifest,
|
||||||
config: &CargoConfig,
|
config: &CargoConfig,
|
||||||
progress: &dyn Fn(String),
|
progress: &dyn Fn(String),
|
||||||
|
) -> Result<ProjectWorkspace> {
|
||||||
|
ProjectWorkspace::load_inner(&manifest, config, progress)
|
||||||
|
.with_context(|| format!("Failed to load the project at {manifest}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_inner(
|
||||||
|
manifest: &ProjectManifest,
|
||||||
|
config: &CargoConfig,
|
||||||
|
progress: &dyn Fn(String),
|
||||||
) -> Result<ProjectWorkspace> {
|
) -> Result<ProjectWorkspace> {
|
||||||
let version = |current_dir, cmd_path, prefix: &str| {
|
let version = |current_dir, cmd_path, prefix: &str| {
|
||||||
let cargo_version = utf8_stdout({
|
let cargo_version = utf8_stdout({
|
||||||
|
@ -534,7 +534,9 @@ fn recreate_crate_graph(&mut self, cause: String) {
|
|||||||
pub(super) fn fetch_workspace_error(&self) -> Result<(), String> {
|
pub(super) fn fetch_workspace_error(&self) -> Result<(), String> {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
|
|
||||||
let Some((last_op_result, _)) = self.fetch_workspaces_queue.last_op_result() else { return Ok(()) };
|
let Some((last_op_result, _)) = self.fetch_workspaces_queue.last_op_result() else {
|
||||||
|
return Ok(())
|
||||||
|
};
|
||||||
if last_op_result.is_empty() {
|
if last_op_result.is_empty() {
|
||||||
stdx::format_to!(buf, "rust-analyzer failed to discover workspace");
|
stdx::format_to!(buf, "rust-analyzer failed to discover workspace");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user