mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
Merge #3939
3939: Fix non canonicallized path from metadata r=matklad a=edwin0cheng Crate root path obtained from cargo-metadata may contains non-canonicalized path (e.g. `/foo/../libcore/tests/lib.rs`), such that `vfs::load` will find a incorrect root. This PR try to fix that by canonicalize it before passing to vfs. Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
commit
54bdb9c78b
2 changed files with 6 additions and 2 deletions
|
@ -152,7 +152,9 @@ pub(crate) fn load(
|
|||
&extern_source_roots,
|
||||
proc_macro_client,
|
||||
&mut |path: &Path| {
|
||||
let vfs_file = vfs.load(path);
|
||||
// Some path from metadata will be non canonicalized, e.g. /foo/../bar/lib.rs
|
||||
let path = path.canonicalize().ok()?;
|
||||
let vfs_file = vfs.load(&path);
|
||||
log::debug!("vfs file {:?} -> {:?}", path, vfs_file);
|
||||
vfs_file.map(vfs_file_to_id)
|
||||
},
|
||||
|
|
|
@ -139,7 +139,9 @@ impl WorldState {
|
|||
// Create crate graph from all the workspaces
|
||||
let mut crate_graph = CrateGraph::default();
|
||||
let mut load = |path: &std::path::Path| {
|
||||
let vfs_file = vfs.load(path);
|
||||
// Some path from metadata will be non canonicalized, e.g. /foo/../bar/lib.rs
|
||||
let path = path.canonicalize().ok()?;
|
||||
let vfs_file = vfs.load(&path);
|
||||
vfs_file.map(|f| FileId(f.0))
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue