diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-09 16:07:33 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-09 16:07:33 +0000 |
commit | 99118eeccdf6564876bbe6ec0672b04ffcbe3442 (patch) | |
tree | 08f0fd7d99ad22a3d1db782482b66548e99ba8b2 /crates/hir_def/src | |
parent | 42be522c80cf0cc2d49b60f3c1d66afdc51fcbbb (diff) | |
parent | 6e24321e4579d25686982002ed18f321db23cb9f (diff) |
Merge #6784
6784: Introduce anchored_path r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r-- | crates/hir_def/src/nameres/mod_resolution.rs | 5 | ||||
-rw-r--r-- | crates/hir_def/src/test_db.rs | 6 |
2 files changed, 6 insertions, 5 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. |
2 | use base_db::FileId; | 2 | use base_db::{AnchoredPath, FileId}; |
3 | use hir_expand::name::Name; | 3 | use hir_expand::name::Name; |
4 | use syntax::SmolStr; | 4 | use syntax::SmolStr; |
5 | use test_utils::mark; | 5 | use 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() { |
diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs index f8b150850..574c0201a 100644 --- a/crates/hir_def/src/test_db.rs +++ b/crates/hir_def/src/test_db.rs | |||
@@ -5,8 +5,8 @@ use std::{ | |||
5 | sync::{Arc, Mutex}, | 5 | sync::{Arc, Mutex}, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use base_db::SourceDatabase; | ||
9 | use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, Upcast}; | 8 | use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, Upcast}; |
9 | use base_db::{AnchoredPath, SourceDatabase}; | ||
10 | use hir_expand::db::AstDatabase; | 10 | use hir_expand::db::AstDatabase; |
11 | use hir_expand::diagnostics::Diagnostic; | 11 | use hir_expand::diagnostics::Diagnostic; |
12 | use hir_expand::diagnostics::DiagnosticSinkBuilder; | 12 | use hir_expand::diagnostics::DiagnosticSinkBuilder; |
@@ -63,8 +63,8 @@ impl FileLoader for TestDB { | |||
63 | fn file_text(&self, file_id: FileId) -> Arc<String> { | 63 | fn file_text(&self, file_id: FileId) -> Arc<String> { |
64 | FileLoaderDelegate(self).file_text(file_id) | 64 | FileLoaderDelegate(self).file_text(file_id) |
65 | } | 65 | } |
66 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> { | 66 | fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> { |
67 | FileLoaderDelegate(self).resolve_path(anchor, path) | 67 | FileLoaderDelegate(self).resolve_path(path) |
68 | } | 68 | } |
69 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> { | 69 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> { |
70 | FileLoaderDelegate(self).relevant_crates(file_id) | 70 | FileLoaderDelegate(self).relevant_crates(file_id) |