diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/krate.rs | 13 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/module.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/module_tree.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 33 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/tests.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/query_definitions.rs | 33 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 2 |
10 files changed, 58 insertions, 73 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 53e84429c..c59b7fbc5 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -52,7 +52,7 @@ pub enum Def { | |||
52 | 52 | ||
53 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 53 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
54 | pub struct Module { | 54 | pub struct Module { |
55 | pub(crate) krate: CrateId, | 55 | pub(crate) krate: Crate, |
56 | pub(crate) module_id: ModuleId, | 56 | pub(crate) module_id: ModuleId, |
57 | } | 57 | } |
58 | 58 | ||
@@ -133,8 +133,8 @@ impl Module { | |||
133 | } | 133 | } |
134 | 134 | ||
135 | /// Returns the crate this module is part of. | 135 | /// Returns the crate this module is part of. |
136 | pub fn krate(&self, db: &impl HirDatabase) -> Option<Crate> { | 136 | pub fn krate(&self, _db: &impl HirDatabase) -> Option<Crate> { |
137 | self.krate_impl(db) | 137 | Some(self.krate) |
138 | } | 138 | } |
139 | 139 | ||
140 | /// Topmost parent of this module. Every module has a `crate_root`, but some | 140 | /// Topmost parent of this module. Every module has a `crate_root`, but some |
diff --git a/crates/ra_hir/src/code_model_impl/krate.rs b/crates/ra_hir/src/code_model_impl/krate.rs index cdd30b402..86f29d959 100644 --- a/crates/ra_hir/src/code_model_impl/krate.rs +++ b/crates/ra_hir/src/code_model_impl/krate.rs | |||
@@ -1,31 +1,28 @@ | |||
1 | use ra_db::CrateId; | ||
2 | |||
3 | use crate::{ | 1 | use crate::{ |
4 | Crate, CrateDependency, AsName, Module, | 2 | Crate, CrateDependency, AsName, Module, |
5 | db::HirDatabase, | 3 | db::HirDatabase, |
6 | }; | 4 | }; |
7 | 5 | ||
8 | impl Crate { | 6 | impl Crate { |
9 | pub(crate) fn new(crate_id: CrateId) -> Crate { | ||
10 | Crate { crate_id } | ||
11 | } | ||
12 | pub(crate) fn dependencies_impl(&self, db: &impl HirDatabase) -> Vec<CrateDependency> { | 7 | pub(crate) fn dependencies_impl(&self, db: &impl HirDatabase) -> Vec<CrateDependency> { |
13 | let crate_graph = db.crate_graph(); | 8 | let crate_graph = db.crate_graph(); |
14 | crate_graph | 9 | crate_graph |
15 | .dependencies(self.crate_id) | 10 | .dependencies(self.crate_id) |
16 | .map(|dep| { | 11 | .map(|dep| { |
17 | let krate = Crate::new(dep.crate_id()); | 12 | let krate = Crate { |
13 | crate_id: dep.crate_id(), | ||
14 | }; | ||
18 | let name = dep.as_name(); | 15 | let name = dep.as_name(); |
19 | CrateDependency { krate, name } | 16 | CrateDependency { krate, name } |
20 | }) | 17 | }) |
21 | .collect() | 18 | .collect() |
22 | } | 19 | } |
23 | pub(crate) fn root_module_impl(&self, db: &impl HirDatabase) -> Option<Module> { | 20 | pub(crate) fn root_module_impl(&self, db: &impl HirDatabase) -> Option<Module> { |
24 | let module_tree = db.module_tree(self.crate_id); | 21 | let module_tree = db.module_tree(*self); |
25 | let module_id = module_tree.modules().next()?; | 22 | let module_id = module_tree.modules().next()?; |
26 | 23 | ||
27 | let module = Module { | 24 | let module = Module { |
28 | krate: self.crate_id, | 25 | krate: *self, |
29 | module_id, | 26 | module_id, |
30 | }; | 27 | }; |
31 | Some(module) | 28 | Some(module) |
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index c6f85ac82..4a3901b8b 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs | |||
@@ -3,7 +3,7 @@ use ra_syntax::{ast, SyntaxNode, TreeArc}; | |||
3 | 3 | ||
4 | use crate::{ | 4 | use crate::{ |
5 | Module, ModuleSource, Problem, | 5 | Module, ModuleSource, Problem, |
6 | Crate, Name, | 6 | Name, |
7 | module_tree::ModuleId, | 7 | module_tree::ModuleId, |
8 | impl_block::ImplId, | 8 | impl_block::ImplId, |
9 | nameres::{lower::ImportId}, | 9 | nameres::{lower::ImportId}, |
@@ -67,10 +67,6 @@ impl Module { | |||
67 | source_map.get(&source, impl_id) | 67 | source_map.get(&source, impl_id) |
68 | } | 68 | } |
69 | 69 | ||
70 | pub(crate) fn krate_impl(&self, _db: &impl HirDatabase) -> Option<Crate> { | ||
71 | Some(Crate::new(self.krate)) | ||
72 | } | ||
73 | |||
74 | pub(crate) fn crate_root_impl(&self, db: &impl HirDatabase) -> Module { | 70 | pub(crate) fn crate_root_impl(&self, db: &impl HirDatabase) -> Module { |
75 | let module_tree = db.module_tree(self.krate); | 71 | let module_tree = db.module_tree(self.krate); |
76 | let module_id = self.module_id.crate_root(&module_tree); | 72 | let module_id = self.module_id.crate_root(&module_tree); |
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 70d9de212..16d5a7877 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::{SyntaxNode, TreeArc, SourceFile}; | 3 | use ra_syntax::{SyntaxNode, TreeArc, SourceFile}; |
4 | use ra_db::{SourceDatabase, CrateId, salsa}; | 4 | use ra_db::{SourceDatabase, salsa}; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | MacroCallId, HirFileId, | 7 | MacroCallId, HirFileId, |
@@ -67,11 +67,11 @@ pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> { | |||
67 | #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)] | 67 | #[salsa::invoke(crate::nameres::lower::LoweredModule::lower_module_source_map_query)] |
68 | fn lower_module_source_map(&self, module: Module) -> Arc<ImportSourceMap>; | 68 | fn lower_module_source_map(&self, module: Module) -> Arc<ImportSourceMap>; |
69 | 69 | ||
70 | #[salsa::invoke(query_definitions::item_map)] | 70 | #[salsa::invoke(crate::nameres::ItemMap::item_map_query)] |
71 | fn item_map(&self, crate_id: CrateId) -> Arc<ItemMap>; | 71 | fn item_map(&self, krate: Crate) -> Arc<ItemMap>; |
72 | 72 | ||
73 | #[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)] | 73 | #[salsa::invoke(crate::module_tree::ModuleTree::module_tree_query)] |
74 | fn module_tree(&self, crate_id: CrateId) -> Arc<ModuleTree>; | 74 | fn module_tree(&self, krate: Crate) -> Arc<ModuleTree>; |
75 | 75 | ||
76 | #[salsa::invoke(crate::impl_block::impls_in_module_with_source_map_query)] | 76 | #[salsa::invoke(crate::impl_block::impls_in_module_with_source_map_query)] |
77 | fn impls_in_module_with_source_map( | 77 | fn impls_in_module_with_source_map( |
diff --git a/crates/ra_hir/src/module_tree.rs b/crates/ra_hir/src/module_tree.rs index 893c375b5..1f327eeb2 100644 --- a/crates/ra_hir/src/module_tree.rs +++ b/crates/ra_hir/src/module_tree.rs | |||
@@ -2,7 +2,7 @@ use std::sync::Arc; | |||
2 | 2 | ||
3 | use arrayvec::ArrayVec; | 3 | use arrayvec::ArrayVec; |
4 | use relative_path::RelativePathBuf; | 4 | use relative_path::RelativePathBuf; |
5 | use ra_db::{FileId, SourceRoot, CrateId}; | 5 | use ra_db::{FileId, SourceRoot}; |
6 | use ra_syntax::{ | 6 | use ra_syntax::{ |
7 | SyntaxNode, TreeArc, | 7 | SyntaxNode, TreeArc, |
8 | algo::generate, | 8 | algo::generate, |
@@ -13,6 +13,7 @@ use test_utils::tested_by; | |||
13 | 13 | ||
14 | use crate::{ | 14 | use crate::{ |
15 | Name, AsName, HirDatabase, SourceItemId, HirFileId, Problem, SourceFileItems, ModuleSource, | 15 | Name, AsName, HirDatabase, SourceItemId, HirFileId, Problem, SourceFileItems, ModuleSource, |
16 | Crate, | ||
16 | ids::SourceFileItemId, | 17 | ids::SourceFileItemId, |
17 | }; | 18 | }; |
18 | 19 | ||
@@ -132,10 +133,10 @@ struct LinkData { | |||
132 | } | 133 | } |
133 | 134 | ||
134 | impl ModuleTree { | 135 | impl ModuleTree { |
135 | pub(crate) fn module_tree_query(db: &impl HirDatabase, crate_id: CrateId) -> Arc<ModuleTree> { | 136 | pub(crate) fn module_tree_query(db: &impl HirDatabase, krate: Crate) -> Arc<ModuleTree> { |
136 | db.check_canceled(); | 137 | db.check_canceled(); |
137 | let mut res = ModuleTree::default(); | 138 | let mut res = ModuleTree::default(); |
138 | res.init_crate(db, crate_id); | 139 | res.init_crate(db, krate); |
139 | Arc::new(res) | 140 | Arc::new(res) |
140 | } | 141 | } |
141 | 142 | ||
@@ -155,9 +156,9 @@ impl ModuleTree { | |||
155 | Some(res) | 156 | Some(res) |
156 | } | 157 | } |
157 | 158 | ||
158 | fn init_crate(&mut self, db: &impl HirDatabase, crate_id: CrateId) { | 159 | fn init_crate(&mut self, db: &impl HirDatabase, krate: Crate) { |
159 | let crate_graph = db.crate_graph(); | 160 | let crate_graph = db.crate_graph(); |
160 | let file_id = crate_graph.crate_root(crate_id); | 161 | let file_id = crate_graph.crate_root(krate.crate_id); |
161 | let source_root_id = db.file_source_root(file_id); | 162 | let source_root_id = db.file_source_root(file_id); |
162 | 163 | ||
163 | let source_root = db.source_root(source_root_id); | 164 | let source_root = db.source_root(source_root_id); |
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 97ce6c946..4573a72ba 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -16,9 +16,8 @@ | |||
16 | //! structure itself is modified. | 16 | //! structure itself is modified. |
17 | pub(crate) mod lower; | 17 | pub(crate) mod lower; |
18 | 18 | ||
19 | use std::sync::Arc; | 19 | use std::{time, sync::Arc}; |
20 | 20 | ||
21 | use ra_db::CrateId; | ||
22 | use ra_arena::map::ArenaMap; | 21 | use ra_arena::map::ArenaMap; |
23 | use test_utils::tested_by; | 22 | use test_utils::tested_by; |
24 | use rustc_hash::{FxHashMap, FxHashSet}; | 23 | use rustc_hash::{FxHashMap, FxHashSet}; |
@@ -156,10 +155,10 @@ impl<T> PerNs<T> { | |||
156 | } | 155 | } |
157 | } | 156 | } |
158 | 157 | ||
159 | pub(crate) struct Resolver<'a, DB> { | 158 | struct Resolver<'a, DB> { |
160 | db: &'a DB, | 159 | db: &'a DB, |
161 | input: &'a FxHashMap<ModuleId, Arc<LoweredModule>>, | 160 | input: &'a FxHashMap<ModuleId, Arc<LoweredModule>>, |
162 | krate: CrateId, | 161 | krate: Crate, |
163 | module_tree: Arc<ModuleTree>, | 162 | module_tree: Arc<ModuleTree>, |
164 | processed_imports: FxHashSet<(ModuleId, ImportId)>, | 163 | processed_imports: FxHashSet<(ModuleId, ImportId)>, |
165 | result: ItemMap, | 164 | result: ItemMap, |
@@ -169,10 +168,10 @@ impl<'a, DB> Resolver<'a, DB> | |||
169 | where | 168 | where |
170 | DB: HirDatabase, | 169 | DB: HirDatabase, |
171 | { | 170 | { |
172 | pub(crate) fn new( | 171 | fn new( |
173 | db: &'a DB, | 172 | db: &'a DB, |
174 | input: &'a FxHashMap<ModuleId, Arc<LoweredModule>>, | 173 | input: &'a FxHashMap<ModuleId, Arc<LoweredModule>>, |
175 | krate: CrateId, | 174 | krate: Crate, |
176 | ) -> Resolver<'a, DB> { | 175 | ) -> Resolver<'a, DB> { |
177 | let module_tree = db.module_tree(krate); | 176 | let module_tree = db.module_tree(krate); |
178 | Resolver { | 177 | Resolver { |
@@ -219,7 +218,7 @@ where | |||
219 | let crate_graph = self.db.crate_graph(); | 218 | let crate_graph = self.db.crate_graph(); |
220 | if let Some(crate_id) = crate_graph.crate_id_for_crate_root(file_id.as_original_file()) | 219 | if let Some(crate_id) = crate_graph.crate_id_for_crate_root(file_id.as_original_file()) |
221 | { | 220 | { |
222 | let krate = Crate::new(crate_id); | 221 | let krate = Crate { crate_id }; |
223 | for dep in krate.dependencies(self.db) { | 222 | for dep in krate.dependencies(self.db) { |
224 | if let Some(module) = dep.krate.root_module(self.db) { | 223 | if let Some(module) = dep.krate.root_module(self.db) { |
225 | let def = module.into(); | 224 | let def = module.into(); |
@@ -331,6 +330,26 @@ enum ReachedFixedPoint { | |||
331 | } | 330 | } |
332 | 331 | ||
333 | impl ItemMap { | 332 | impl ItemMap { |
333 | pub(crate) fn item_map_query(db: &impl HirDatabase, krate: Crate) -> Arc<ItemMap> { | ||
334 | let start = time::Instant::now(); | ||
335 | let module_tree = db.module_tree(krate); | ||
336 | let input = module_tree | ||
337 | .modules() | ||
338 | .map(|module_id| { | ||
339 | ( | ||
340 | module_id, | ||
341 | db.lower_module_module(Module { krate, module_id }), | ||
342 | ) | ||
343 | }) | ||
344 | .collect::<FxHashMap<_, _>>(); | ||
345 | |||
346 | let resolver = Resolver::new(db, &input, krate); | ||
347 | let res = resolver.resolve(); | ||
348 | let elapsed = start.elapsed(); | ||
349 | log::info!("item_map: {:?}", elapsed); | ||
350 | Arc::new(res) | ||
351 | } | ||
352 | |||
334 | pub(crate) fn resolve_path( | 353 | pub(crate) fn resolve_path( |
335 | &self, | 354 | &self, |
336 | db: &impl HirDatabase, | 355 | db: &impl HirDatabase, |
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs index 3d420467c..9c5ca097e 100644 --- a/crates/ra_hir/src/nameres/tests.rs +++ b/crates/ra_hir/src/nameres/tests.rs | |||
@@ -16,7 +16,7 @@ fn item_map(fixture: &str) -> (Arc<ItemMap>, ModuleId) { | |||
16 | let module = crate::source_binder::module_from_position(&db, pos).unwrap(); | 16 | let module = crate::source_binder::module_from_position(&db, pos).unwrap(); |
17 | let krate = module.krate(&db).unwrap(); | 17 | let krate = module.krate(&db).unwrap(); |
18 | let module_id = module.module_id; | 18 | let module_id = module.module_id; |
19 | (db.item_map(krate.crate_id), module_id) | 19 | (db.item_map(krate), module_id) |
20 | } | 20 | } |
21 | 21 | ||
22 | /// Sets the crate root to the file of the cursor marker | 22 | /// Sets the crate root to the file of the cursor marker |
@@ -30,7 +30,7 @@ fn item_map_custom_crate_root(fixture: &str) -> (Arc<ItemMap>, ModuleId) { | |||
30 | let module = crate::source_binder::module_from_position(&db, pos).unwrap(); | 30 | let module = crate::source_binder::module_from_position(&db, pos).unwrap(); |
31 | let krate = module.krate(&db).unwrap(); | 31 | let krate = module.krate(&db).unwrap(); |
32 | let module_id = module.module_id; | 32 | let module_id = module.module_id; |
33 | (db.item_map(krate.crate_id), module_id) | 33 | (db.item_map(krate), module_id) |
34 | } | 34 | } |
35 | 35 | ||
36 | fn check_module_item_map(map: &ItemMap, module_id: ModuleId, expected: &str) { | 36 | fn check_module_item_map(map: &ItemMap, module_id: ModuleId, expected: &str) { |
@@ -297,7 +297,7 @@ fn item_map_across_crates() { | |||
297 | 297 | ||
298 | let module = crate::source_binder::module_from_file_id(&db, main_id).unwrap(); | 298 | let module = crate::source_binder::module_from_file_id(&db, main_id).unwrap(); |
299 | let krate = module.krate(&db).unwrap(); | 299 | let krate = module.krate(&db).unwrap(); |
300 | let item_map = db.item_map(krate.crate_id); | 300 | let item_map = db.item_map(krate); |
301 | 301 | ||
302 | check_module_item_map( | 302 | check_module_item_map( |
303 | &item_map, | 303 | &item_map, |
@@ -349,7 +349,7 @@ fn import_across_source_roots() { | |||
349 | 349 | ||
350 | let module = crate::source_binder::module_from_file_id(&db, main_id).unwrap(); | 350 | let module = crate::source_binder::module_from_file_id(&db, main_id).unwrap(); |
351 | let krate = module.krate(&db).unwrap(); | 351 | let krate = module.krate(&db).unwrap(); |
352 | let item_map = db.item_map(krate.crate_id); | 352 | let item_map = db.item_map(krate); |
353 | 353 | ||
354 | check_module_item_map( | 354 | check_module_item_map( |
355 | &item_map, | 355 | &item_map, |
@@ -391,7 +391,7 @@ fn reexport_across_crates() { | |||
391 | 391 | ||
392 | let module = crate::source_binder::module_from_file_id(&db, main_id).unwrap(); | 392 | let module = crate::source_binder::module_from_file_id(&db, main_id).unwrap(); |
393 | let krate = module.krate(&db).unwrap(); | 393 | let krate = module.krate(&db).unwrap(); |
394 | let item_map = db.item_map(krate.crate_id); | 394 | let item_map = db.item_map(krate); |
395 | 395 | ||
396 | check_module_item_map( | 396 | check_module_item_map( |
397 | &item_map, | 397 | &item_map, |
@@ -409,7 +409,7 @@ fn check_item_map_is_not_recomputed(initial: &str, file_change: &str) { | |||
409 | let krate = module.krate(&db).unwrap(); | 409 | let krate = module.krate(&db).unwrap(); |
410 | { | 410 | { |
411 | let events = db.log_executed(|| { | 411 | let events = db.log_executed(|| { |
412 | db.item_map(krate.crate_id); | 412 | db.item_map(krate); |
413 | }); | 413 | }); |
414 | assert!(format!("{:?}", events).contains("item_map")) | 414 | assert!(format!("{:?}", events).contains("item_map")) |
415 | } | 415 | } |
@@ -417,7 +417,7 @@ fn check_item_map_is_not_recomputed(initial: &str, file_change: &str) { | |||
417 | 417 | ||
418 | { | 418 | { |
419 | let events = db.log_executed(|| { | 419 | let events = db.log_executed(|| { |
420 | db.item_map(krate.crate_id); | 420 | db.item_map(krate); |
421 | }); | 421 | }); |
422 | assert!( | 422 | assert!( |
423 | !format!("{:?}", events).contains("item_map"), | 423 | !format!("{:?}", events).contains("item_map"), |
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index bf9ac0dfb..6724649e1 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs | |||
@@ -1,17 +1,11 @@ | |||
1 | use std::{ | 1 | use std::sync::Arc; |
2 | sync::Arc, | ||
3 | time::Instant, | ||
4 | }; | ||
5 | 2 | ||
6 | use rustc_hash::FxHashMap; | ||
7 | use ra_syntax::{SyntaxNode, TreeArc}; | 3 | use ra_syntax::{SyntaxNode, TreeArc}; |
8 | use ra_db::{CrateId}; | ||
9 | 4 | ||
10 | use crate::{ | 5 | use crate::{ |
11 | SourceFileItems, SourceItemId, HirFileId, | 6 | SourceFileItems, SourceItemId, HirFileId, |
12 | Function, FnScopes, Module, | 7 | Function, FnScopes, |
13 | db::HirDatabase, | 8 | db::HirDatabase, |
14 | nameres::{ItemMap, Resolver}, | ||
15 | }; | 9 | }; |
16 | 10 | ||
17 | pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes> { | 11 | pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes> { |
@@ -35,26 +29,3 @@ pub(super) fn file_item( | |||
35 | .to_node(&source_file) | 29 | .to_node(&source_file) |
36 | .to_owned() | 30 | .to_owned() |
37 | } | 31 | } |
38 | |||
39 | pub(super) fn item_map(db: &impl HirDatabase, crate_id: CrateId) -> Arc<ItemMap> { | ||
40 | let start = Instant::now(); | ||
41 | let module_tree = db.module_tree(crate_id); | ||
42 | let input = module_tree | ||
43 | .modules() | ||
44 | .map(|module_id| { | ||
45 | ( | ||
46 | module_id, | ||
47 | db.lower_module_module(Module { | ||
48 | krate: crate_id, | ||
49 | module_id, | ||
50 | }), | ||
51 | ) | ||
52 | }) | ||
53 | .collect::<FxHashMap<_, _>>(); | ||
54 | |||
55 | let resolver = Resolver::new(db, &input, crate_id); | ||
56 | let res = resolver.resolve(); | ||
57 | let elapsed = start.elapsed(); | ||
58 | log::info!("item_map: {:?}", elapsed); | ||
59 | Arc::new(res) | ||
60 | } | ||
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 589efd023..d1eaccf23 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -14,7 +14,7 @@ use ra_syntax::{ | |||
14 | 14 | ||
15 | use crate::{ | 15 | use crate::{ |
16 | HirDatabase, Function, ModuleDef, Struct, Enum, | 16 | HirDatabase, Function, ModuleDef, Struct, Enum, |
17 | AsName, Module, HirFileId, | 17 | AsName, Module, HirFileId, Crate, |
18 | ids::{LocationCtx, SourceFileItemId}, | 18 | ids::{LocationCtx, SourceFileItemId}, |
19 | }; | 19 | }; |
20 | 20 | ||
@@ -83,7 +83,8 @@ fn module_from_source( | |||
83 | let source_root_id = db.file_source_root(file_id.as_original_file()); | 83 | let source_root_id = db.file_source_root(file_id.as_original_file()); |
84 | db.source_root_crates(source_root_id) | 84 | db.source_root_crates(source_root_id) |
85 | .iter() | 85 | .iter() |
86 | .find_map(|&krate| { | 86 | .map(|&crate_id| Crate { crate_id }) |
87 | .find_map(|krate| { | ||
87 | let module_tree = db.module_tree(krate); | 88 | let module_tree = db.module_tree(krate); |
88 | let module_id = module_tree.find_module_by_source(file_id, decl_id)?; | 89 | let module_id = module_tree.find_module_by_source(file_id, decl_id)?; |
89 | Some(Module { krate, module_id }) | 90 | Some(Module { krate, module_id }) |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index d70a24582..37bc3f38c 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -52,7 +52,7 @@ impl CrateImplBlocks { | |||
52 | .flat_map(|i| i.iter()) | 52 | .flat_map(|i| i.iter()) |
53 | .map(move |(module_id, impl_id)| { | 53 | .map(move |(module_id, impl_id)| { |
54 | let module = Module { | 54 | let module = Module { |
55 | krate: self.krate.crate_id, | 55 | krate: self.krate, |
56 | module_id: *module_id, | 56 | module_id: *module_id, |
57 | }; | 57 | }; |
58 | let module_impl_blocks = db.impls_in_module(module); | 58 | let module_impl_blocks = db.impls_in_module(module); |