diff options
Diffstat (limited to 'crates/ra_hir/src/code_model_impl/krate.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/krate.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/ra_hir/src/code_model_impl/krate.rs b/crates/ra_hir/src/code_model_impl/krate.rs index 591a81597..3275eafed 100644 --- a/crates/ra_hir/src/code_model_impl/krate.rs +++ b/crates/ra_hir/src/code_model_impl/krate.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use ra_db::{CrateId, Cancelable}; | 1 | use ra_db::{CrateId, Cancelable}; |
2 | 2 | ||
3 | use crate::{ | 3 | use crate::{ |
4 | HirFileId, Crate, CrateDependency, AsName, DefLoc, DefKind, Module, | 4 | HirFileId, Crate, CrateDependency, AsName, DefLoc, DefKind, Module, SourceItemId, |
5 | db::HirDatabase, | 5 | db::HirDatabase, |
6 | }; | 6 | }; |
7 | 7 | ||
@@ -27,15 +27,17 @@ impl Crate { | |||
27 | let file_id = HirFileId::from(file_id); | 27 | let file_id = HirFileId::from(file_id); |
28 | let module_tree = db.module_tree(source_root_id)?; | 28 | let module_tree = db.module_tree(source_root_id)?; |
29 | // FIXME: teach module tree about crate roots instead of guessing | 29 | // FIXME: teach module tree about crate roots instead of guessing |
30 | let (module_id, _) = ctry!(module_tree | 30 | let source = SourceItemId { |
31 | .modules_with_sources() | 31 | file_id, |
32 | .find(|(_, src)| src.file_id() == file_id)); | 32 | item_id: None, |
33 | }; | ||
34 | let module_id = ctry!(module_tree.find_module_by_source(source)); | ||
33 | 35 | ||
34 | let def_loc = DefLoc { | 36 | let def_loc = DefLoc { |
35 | kind: DefKind::Module, | 37 | kind: DefKind::Module, |
36 | source_root_id, | 38 | source_root_id, |
37 | module_id, | 39 | module_id, |
38 | source_item_id: module_id.source(&module_tree).0, | 40 | source_item_id: module_id.source(&module_tree), |
39 | }; | 41 | }; |
40 | let def_id = def_loc.id(db); | 42 | let def_id = def_loc.id(db); |
41 | 43 | ||