diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 37d0f3093..c9ccb9023 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -19,7 +19,7 @@ use crate::{ | |||
19 | per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode, | 19 | per_ns::PerNs, raw, CrateDefMap, ModuleData, Resolution, ResolveMode, |
20 | }, | 20 | }, |
21 | path::{Path, PathKind}, | 21 | path::{Path, PathKind}, |
22 | AdtId, AstId, AstItemDef, ConstId, CrateModuleId, EnumId, EnumVariantId, FunctionId, | 22 | AdtId, AstId, AstItemDef, ConstId, CrateModuleId, EnumId, EnumVariantId, FunctionId, ImplId, |
23 | LocationCtx, ModuleDefId, ModuleId, StaticId, StructId, StructOrUnionId, TraitId, TypeAliasId, | 23 | LocationCtx, ModuleDefId, ModuleId, StaticId, StructId, StructOrUnionId, TraitId, TypeAliasId, |
24 | UnionId, | 24 | UnionId, |
25 | }; | 25 | }; |
@@ -571,6 +571,15 @@ where | |||
571 | .push((self.module_id, import_id, self.raw_items[import_id].clone())), | 571 | .push((self.module_id, import_id, self.raw_items[import_id].clone())), |
572 | raw::RawItemKind::Def(def) => self.define_def(&self.raw_items[def]), | 572 | raw::RawItemKind::Def(def) => self.define_def(&self.raw_items[def]), |
573 | raw::RawItemKind::Macro(mac) => self.collect_macro(&self.raw_items[mac]), | 573 | raw::RawItemKind::Macro(mac) => self.collect_macro(&self.raw_items[mac]), |
574 | raw::RawItemKind::Impl(imp) => { | ||
575 | let module = ModuleId { | ||
576 | krate: self.def_collector.def_map.krate, | ||
577 | module_id: self.module_id, | ||
578 | }; | ||
579 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); | ||
580 | let imp_id = ImplId::from_ast_id(ctx, self.raw_items[imp].ast_id); | ||
581 | self.def_collector.def_map.modules[self.module_id].impls.push(imp_id) | ||
582 | } | ||
574 | } | 583 | } |
575 | } | 584 | } |
576 | } | 585 | } |
@@ -664,7 +673,8 @@ where | |||
664 | let name = def.name.clone(); | 673 | let name = def.name.clone(); |
665 | let def: PerNs = match def.kind { | 674 | let def: PerNs = match def.kind { |
666 | raw::DefKind::Function(ast_id) => { | 675 | raw::DefKind::Function(ast_id) => { |
667 | PerNs::values(FunctionId::from_ast_id(ctx, ast_id).into()) | 676 | let f = FunctionId::from_ast_id(ctx, ast_id); |
677 | PerNs::values(f.into()) | ||
668 | } | 678 | } |
669 | raw::DefKind::Struct(ast_id) => { | 679 | raw::DefKind::Struct(ast_id) => { |
670 | let id = StructOrUnionId::from_ast_id(ctx, ast_id).into(); | 680 | let id = StructOrUnionId::from_ast_id(ctx, ast_id).into(); |
@@ -798,7 +808,7 @@ mod tests { | |||
798 | 808 | ||
799 | fn do_limited_resolve(code: &str, limit: u32, poison_limit: u32) -> CrateDefMap { | 809 | fn do_limited_resolve(code: &str, limit: u32, poison_limit: u32) -> CrateDefMap { |
800 | let (db, _file_id) = TestDB::with_single_file(&code); | 810 | let (db, _file_id) = TestDB::with_single_file(&code); |
801 | let krate = db.crate_graph().iter().next().unwrap(); | 811 | let krate = db.test_crate(); |
802 | 812 | ||
803 | let def_map = { | 813 | let def_map = { |
804 | let edition = db.crate_graph().edition(krate); | 814 | let edition = db.crate_graph().edition(krate); |