From 6e24321e4579d25686982002ed18f321db23cb9f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 9 Dec 2020 19:01:15 +0300 Subject: Introduce anchored_path They allow to represent paths like `#[path = "C:\path.rs"] mod foo;` in a lossless cross-platform & network-transparent way. --- crates/hir_def/src/nameres/mod_resolution.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crates/hir_def/src/nameres') diff --git a/crates/hir_def/src/nameres/mod_resolution.rs b/crates/hir_def/src/nameres/mod_resolution.rs index c0c789cae..b4ccd4488 100644 --- a/crates/hir_def/src/nameres/mod_resolution.rs +++ b/crates/hir_def/src/nameres/mod_resolution.rs @@ -1,5 +1,5 @@ //! This module resolves `mod foo;` declaration to file. -use base_db::FileId; +use base_db::{AnchoredPath, FileId}; use hir_expand::name::Name; use syntax::SmolStr; use test_utils::mark; @@ -77,7 +77,8 @@ impl ModDir { }; for candidate in candidate_files.iter() { - if let Some(file_id) = db.resolve_path(file_id, candidate.as_str()) { + let path = AnchoredPath { anchor: file_id, path: candidate.as_str() }; + if let Some(file_id) = db.resolve_path(path) { let is_mod_rs = candidate.ends_with("mod.rs"); let (dir_path, root_non_dir_owner) = if is_mod_rs || attr_path.is_some() { -- cgit v1.2.3