Fix non canonicallized path for crate file

This commit is contained in:
Edwin Cheng 2020-04-11 18:12:50 +08:00
parent beb755caa2
commit 73e512215a
2 changed files with 6 additions and 2 deletions

View file

@ -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)
},

View file

@ -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))
};