From 73e512215afada62316a7b057bd78d8c9727adca Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 11 Apr 2020 18:12:50 +0800 Subject: Fix non canonicallized path for crate file --- crates/rust-analyzer/src/cli/load_cargo.rs | 4 +++- crates/rust-analyzer/src/world.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index 69133e4e4..43062ea10 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs @@ -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) }, diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs index 365f57d8c..6c42e1d76 100644 --- a/crates/rust-analyzer/src/world.rs +++ b/crates/rust-analyzer/src/world.rs @@ -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)) }; -- cgit v1.2.3