From 3c72fc05738b8a08dbf90dab18a15b9894d9e2a1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 16 Jun 2020 18:45:58 +0200 Subject: Anchor file-system operations to the file, and not to the source root. Anchoring to the SourceRoot wont' work if the path is absolute: #[path = "/tmp/foo.rs"] mod foo; Anchoring to a file will. However, we *should* anchor, instead of just producing an abs path. I can imagine a situation where, for example, rust-analyzer processes crates from different machines (or, for example, from in-memory git branch), where the same absolute path in different crates might refer to different files in the end! --- crates/ra_hir_def/src/nameres/mod_resolution.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir_def/src/nameres') diff --git a/crates/ra_hir_def/src/nameres/mod_resolution.rs b/crates/ra_hir_def/src/nameres/mod_resolution.rs index cede4a6fc..19fe0615a 100644 --- a/crates/ra_hir_def/src/nameres/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/mod_resolution.rs @@ -44,7 +44,7 @@ impl ModDir { file_id: HirFileId, name: &Name, attr_path: Option<&SmolStr>, - ) -> Result<(FileId, ModDir), RelativePathBuf> { + ) -> Result<(FileId, ModDir), String> { let file_id = file_id.original_file(db.upcast()); let mut candidate_files = Vec::new(); @@ -52,11 +52,11 @@ impl ModDir { Some(attr_path) => { let base = if self.root_non_dir_owner { self.path.parent().unwrap() } else { &self.path }; - candidate_files.push(base.join(attr_path)) + candidate_files.push(base.join(attr_path).to_string()) } None => { - candidate_files.push(self.path.join(&format!("{}.rs", name))); - candidate_files.push(self.path.join(&format!("{}/mod.rs", name))); + candidate_files.push(self.path.join(&format!("{}.rs", name)).to_string()); + candidate_files.push(self.path.join(&format!("{}/mod.rs", name)).to_string()); } }; -- cgit v1.2.3