aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/mock.rs2
-rw-r--r--crates/ra_hir/src/nameres/mod_resolution.rs14
2 files changed, 9 insertions, 7 deletions
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index 77a44a275..972f0ece5 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -157,7 +157,7 @@ impl MockDatabase {
157 self.set_file_text(file_id, text); 157 self.set_file_text(file_id, text);
158 self.set_file_relative_path(file_id, rel_path.clone()); 158 self.set_file_relative_path(file_id, rel_path.clone());
159 self.set_file_source_root(file_id, source_root_id); 159 self.set_file_source_root(file_id, source_root_id);
160 source_root.files.insert(rel_path, file_id); 160 source_root.insert_file(rel_path, file_id);
161 161
162 if is_crate_root { 162 if is_crate_root {
163 let mut crate_graph = CrateGraph::default(); 163 let mut crate_graph = CrateGraph::default();
diff --git a/crates/ra_hir/src/nameres/mod_resolution.rs b/crates/ra_hir/src/nameres/mod_resolution.rs
index 94c9946ff..de81fd422 100644
--- a/crates/ra_hir/src/nameres/mod_resolution.rs
+++ b/crates/ra_hir/src/nameres/mod_resolution.rs
@@ -120,10 +120,12 @@ enum OutOfLineMode {
120impl OutOfLineMode { 120impl OutOfLineMode {
121 pub fn resolve(&self, source_root: Arc<SourceRoot>) -> Result<FileId, RelativePathBuf> { 121 pub fn resolve(&self, source_root: Arc<SourceRoot>) -> Result<FileId, RelativePathBuf> {
122 match self { 122 match self {
123 OutOfLineMode::RootOrModRs { file, directory } => match source_root.files.get(file) { 123 OutOfLineMode::RootOrModRs { file, directory } => {
124 None => resolve_simple_path(source_root, directory).map_err(|_| file.clone()), 124 match source_root.file_by_relative_path(file) {
125 file_id => resolve_find_result(file_id, file), 125 None => resolve_simple_path(source_root, directory).map_err(|_| file.clone()),
126 }, 126 file_id => resolve_find_result(file_id, file),
127 }
128 }
127 OutOfLineMode::FileInDirectory(path) => resolve_simple_path(source_root, path), 129 OutOfLineMode::FileInDirectory(path) => resolve_simple_path(source_root, path),
128 OutOfLineMode::WithAttributePath(path) => resolve_simple_path(source_root, path), 130 OutOfLineMode::WithAttributePath(path) => resolve_simple_path(source_root, path),
129 } 131 }
@@ -168,11 +170,11 @@ fn resolve_simple_path(
168 source_root: Arc<SourceRoot>, 170 source_root: Arc<SourceRoot>,
169 path: &RelativePathBuf, 171 path: &RelativePathBuf,
170) -> Result<FileId, RelativePathBuf> { 172) -> Result<FileId, RelativePathBuf> {
171 resolve_find_result(source_root.files.get(path), path) 173 resolve_find_result(source_root.file_by_relative_path(path), path)
172} 174}
173 175
174fn resolve_find_result( 176fn resolve_find_result(
175 file_id: Option<&FileId>, 177 file_id: Option<FileId>,
176 path: &RelativePathBuf, 178 path: &RelativePathBuf,
177) -> Result<FileId, RelativePathBuf> { 179) -> Result<FileId, RelativePathBuf> {
178 match file_id { 180 match file_id {