diff options
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 32afd8e0a..88ad0a44d 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -19,6 +19,7 @@ pub(crate) mod lower; | |||
19 | use std::sync::Arc; | 19 | use std::sync::Arc; |
20 | 20 | ||
21 | use ra_db::CrateId; | 21 | use ra_db::CrateId; |
22 | use ra_arena::map::ArenaMap; | ||
22 | use test_utils::tested_by; | 23 | use test_utils::tested_by; |
23 | use rustc_hash::{FxHashMap, FxHashSet}; | 24 | use rustc_hash::{FxHashMap, FxHashSet}; |
24 | 25 | ||
@@ -37,7 +38,14 @@ use crate::{ | |||
37 | // FIXME: currenty we compute item map per source-root. We should do it per crate instead. | 38 | // FIXME: currenty we compute item map per source-root. We should do it per crate instead. |
38 | #[derive(Default, Debug, PartialEq, Eq)] | 39 | #[derive(Default, Debug, PartialEq, Eq)] |
39 | pub struct ItemMap { | 40 | pub struct ItemMap { |
40 | pub per_module: FxHashMap<ModuleId, ModuleScope>, | 41 | per_module: ArenaMap<ModuleId, ModuleScope>, |
42 | } | ||
43 | |||
44 | impl std::ops::Index<ModuleId> for ItemMap { | ||
45 | type Output = ModuleScope; | ||
46 | fn index(&self, id: ModuleId) -> &ModuleScope { | ||
47 | &self.per_module[id] | ||
48 | } | ||
41 | } | 49 | } |
42 | 50 | ||
43 | #[derive(Debug, Default, PartialEq, Eq, Clone)] | 51 | #[derive(Debug, Default, PartialEq, Eq, Clone)] |
@@ -308,7 +316,7 @@ where | |||
308 | } | 316 | } |
309 | 317 | ||
310 | fn update(&mut self, module_id: ModuleId, f: impl FnOnce(&mut ModuleScope)) { | 318 | fn update(&mut self, module_id: ModuleId, f: impl FnOnce(&mut ModuleScope)) { |
311 | let module_items = self.result.per_module.get_mut(&module_id).unwrap(); | 319 | let module_items = self.result.per_module.get_mut(module_id).unwrap(); |
312 | f(module_items) | 320 | f(module_items) |
313 | } | 321 | } |
314 | } | 322 | } |
@@ -380,7 +388,7 @@ impl ItemMap { | |||
380 | return (def, ReachedFixedPoint::Yes); | 388 | return (def, ReachedFixedPoint::Yes); |
381 | } | 389 | } |
382 | 390 | ||
383 | match self.per_module[&module.module_id].items.get(&segment.name) { | 391 | match self[module.module_id].items.get(&segment.name) { |
384 | Some(res) if !res.def.is_none() => res.def, | 392 | Some(res) if !res.def.is_none() => res.def, |
385 | _ => { | 393 | _ => { |
386 | log::debug!("path segment {:?} not found", segment.name); | 394 | log::debug!("path segment {:?} not found", segment.name); |