diff options
Diffstat (limited to 'crates/ra_hir/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 4fb298155..e6fd8632a 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -3,6 +3,7 @@ use rustc_hash::FxHashMap; | |||
3 | use relative_path::RelativePathBuf; | 3 | use relative_path::RelativePathBuf; |
4 | use test_utils::tested_by; | 4 | use test_utils::tested_by; |
5 | use ra_db::FileId; | 5 | use ra_db::FileId; |
6 | use ra_syntax::ast; | ||
6 | 7 | ||
7 | use crate::{ | 8 | use crate::{ |
8 | Function, Module, Struct, Enum, Const, Static, Trait, TypeAlias, | 9 | Function, Module, Struct, Enum, Const, Static, Trait, TypeAlias, |
@@ -15,6 +16,7 @@ use crate::{ | |||
15 | raw, | 16 | raw, |
16 | }, | 17 | }, |
17 | ids::{AstItemDef, LocationCtx, MacroCallLoc, MacroCallId, MacroDefId}, | 18 | ids::{AstItemDef, LocationCtx, MacroCallLoc, MacroCallId, MacroDefId}, |
19 | AstId, | ||
18 | }; | 20 | }; |
19 | 21 | ||
20 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { | 22 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { |
@@ -364,12 +366,9 @@ where | |||
364 | fn collect_module(&mut self, module: &raw::ModuleData) { | 366 | fn collect_module(&mut self, module: &raw::ModuleData) { |
365 | match module { | 367 | match module { |
366 | // inline module, just recurse | 368 | // inline module, just recurse |
367 | raw::ModuleData::Definition { name, items, source_item_id } => { | 369 | raw::ModuleData::Definition { name, items, ast_id } => { |
368 | let module_id = self.push_child_module( | 370 | let module_id = |
369 | name.clone(), | 371 | self.push_child_module(name.clone(), ast_id.with_file_id(self.file_id), None); |
370 | source_item_id.with_file_id(self.file_id), | ||
371 | None, | ||
372 | ); | ||
373 | ModCollector { | 372 | ModCollector { |
374 | def_collector: &mut *self.def_collector, | 373 | def_collector: &mut *self.def_collector, |
375 | module_id, | 374 | module_id, |
@@ -379,13 +378,12 @@ where | |||
379 | .collect(&*items); | 378 | .collect(&*items); |
380 | } | 379 | } |
381 | // out of line module, resovle, parse and recurse | 380 | // out of line module, resovle, parse and recurse |
382 | raw::ModuleData::Declaration { name, source_item_id } => { | 381 | raw::ModuleData::Declaration { name, ast_id } => { |
383 | let source_item_id = source_item_id.with_file_id(self.file_id); | 382 | let ast_id = ast_id.with_file_id(self.file_id); |
384 | let is_root = self.def_collector.def_map.modules[self.module_id].parent.is_none(); | 383 | let is_root = self.def_collector.def_map.modules[self.module_id].parent.is_none(); |
385 | match resolve_submodule(self.def_collector.db, self.file_id, name, is_root) { | 384 | match resolve_submodule(self.def_collector.db, self.file_id, name, is_root) { |
386 | Ok(file_id) => { | 385 | Ok(file_id) => { |
387 | let module_id = | 386 | let module_id = self.push_child_module(name.clone(), ast_id, Some(file_id)); |
388 | self.push_child_module(name.clone(), source_item_id, Some(file_id)); | ||
389 | let raw_items = self.def_collector.db.raw_items(file_id.into()); | 387 | let raw_items = self.def_collector.db.raw_items(file_id.into()); |
390 | ModCollector { | 388 | ModCollector { |
391 | def_collector: &mut *self.def_collector, | 389 | def_collector: &mut *self.def_collector, |
@@ -398,7 +396,7 @@ where | |||
398 | Err(candidate) => self.def_collector.def_map.diagnostics.push( | 396 | Err(candidate) => self.def_collector.def_map.diagnostics.push( |
399 | DefDiagnostic::UnresolvedModule { | 397 | DefDiagnostic::UnresolvedModule { |
400 | module: self.module_id, | 398 | module: self.module_id, |
401 | declaration: source_item_id, | 399 | declaration: ast_id, |
402 | candidate, | 400 | candidate, |
403 | }, | 401 | }, |
404 | ), | 402 | ), |
@@ -410,7 +408,7 @@ where | |||
410 | fn push_child_module( | 408 | fn push_child_module( |
411 | &mut self, | 409 | &mut self, |
412 | name: Name, | 410 | name: Name, |
413 | declaration: SourceItemId, | 411 | declaration: AstId<ast::Module>, |
414 | definition: Option<FileId>, | 412 | definition: Option<FileId>, |
415 | ) -> CrateModuleId { | 413 | ) -> CrateModuleId { |
416 | let modules = &mut self.def_collector.def_map.modules; | 414 | let modules = &mut self.def_collector.def_map.modules; |