mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Canonicalize rust-project.json manifest path
This commit is contained in:
parent
284c1741d6
commit
f1de133820
3 changed files with 12 additions and 7 deletions
|
@ -34,6 +34,11 @@ impl ManifestPath {
|
|||
pub fn parent(&self) -> &AbsPath {
|
||||
self.file.parent().unwrap()
|
||||
}
|
||||
|
||||
/// Equivalent of [`Path::canonicalize`] for `ManifestPath`.
|
||||
pub fn canonicalize(&self) -> Result<ManifestPath, std::io::Error> {
|
||||
Ok((&**self).canonicalize()?.try_into().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Deref for ManifestPath {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use std::{collections::VecDeque, fmt, fs, process::Command, sync::Arc};
|
||||
|
||||
use anyhow::{bail, format_err, Context, Result};
|
||||
use anyhow::{format_err, Context, Result};
|
||||
use base_db::{
|
||||
CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env,
|
||||
FileId, LangCrateOrigin, ProcMacroPaths, TargetLayoutLoadResult,
|
||||
|
@ -154,12 +154,7 @@ impl ProjectWorkspace {
|
|||
) -> Result<ProjectWorkspace> {
|
||||
let res = match manifest {
|
||||
ProjectManifest::ProjectJson(project_json) => {
|
||||
let metadata = fs::symlink_metadata(&project_json).with_context(|| {
|
||||
format!("Failed to read json file {}", project_json.display())
|
||||
})?;
|
||||
if metadata.is_symlink() {
|
||||
bail!("The project-json may not currently point to a symlink");
|
||||
}
|
||||
let project_json = project_json.canonicalize()?;
|
||||
let file = fs::read_to_string(&project_json).with_context(|| {
|
||||
format!("Failed to read json file {}", project_json.display())
|
||||
})?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue