aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres/mod_resolution.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-12-09 16:01:15 +0000
committerAleksey Kladov <[email protected]>2020-12-09 16:07:05 +0000
commit6e24321e4579d25686982002ed18f321db23cb9f (patch)
tree08f0fd7d99ad22a3d1db782482b66548e99ba8b2 /crates/hir_def/src/nameres/mod_resolution.rs
parent5e3891c2559de5a6540d69bc14ded281484479f9 (diff)
Introduce anchored_path
They allow to represent paths like `#[path = "C:\path.rs"] mod foo;` in a lossless cross-platform & network-transparent way.
Diffstat (limited to 'crates/hir_def/src/nameres/mod_resolution.rs')
-rw-r--r--crates/hir_def/src/nameres/mod_resolution.rs5
1 files changed, 3 insertions, 2 deletions
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 @@
1//! This module resolves `mod foo;` declaration to file. 1//! This module resolves `mod foo;` declaration to file.
2use base_db::FileId; 2use base_db::{AnchoredPath, FileId};
3use hir_expand::name::Name; 3use hir_expand::name::Name;
4use syntax::SmolStr; 4use syntax::SmolStr;
5use test_utils::mark; 5use test_utils::mark;
@@ -77,7 +77,8 @@ impl ModDir {
77 }; 77 };
78 78
79 for candidate in candidate_files.iter() { 79 for candidate in candidate_files.iter() {
80 if let Some(file_id) = db.resolve_path(file_id, candidate.as_str()) { 80 let path = AnchoredPath { anchor: file_id, path: candidate.as_str() };
81 if let Some(file_id) = db.resolve_path(path) {
81 let is_mod_rs = candidate.ends_with("mod.rs"); 82 let is_mod_rs = candidate.ends_with("mod.rs");
82 83
83 let (dir_path, root_non_dir_owner) = if is_mod_rs || attr_path.is_some() { 84 let (dir_path, root_non_dir_owner) = if is_mod_rs || attr_path.is_some() {