aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs28
1 files changed, 21 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index d2ed94a87..aae3dcadf 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -19,9 +19,9 @@ 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, FunctionContainerId, 22 AdtId, AstId, AstItemDef, ConstLoc, ContainerId, CrateModuleId, EnumId, EnumVariantId,
23 FunctionLoc, ImplId, Intern, LocationCtx, ModuleDefId, ModuleId, StaticId, StructId, 23 FunctionLoc, ImplId, Intern, LocationCtx, ModuleDefId, ModuleId, StaticId, StructId,
24 StructOrUnionId, TraitId, TypeAliasId, UnionId, 24 StructOrUnionId, TraitId, TypeAliasLoc, UnionId,
25}; 25};
26 26
27pub(super) fn collect_defs(db: &impl DefDatabase2, mut def_map: CrateDefMap) -> CrateDefMap { 27pub(super) fn collect_defs(db: &impl DefDatabase2, mut def_map: CrateDefMap) -> CrateDefMap {
@@ -673,13 +673,13 @@ where
673 let name = def.name.clone(); 673 let name = def.name.clone();
674 let def: PerNs = match def.kind { 674 let def: PerNs = match def.kind {
675 raw::DefKind::Function(ast_id) => { 675 raw::DefKind::Function(ast_id) => {
676 let f = FunctionLoc { 676 let def = FunctionLoc {
677 container: FunctionContainerId::ModuleId(module), 677 container: ContainerId::ModuleId(module),
678 ast_id: AstId::new(self.file_id, ast_id), 678 ast_id: AstId::new(self.file_id, ast_id),
679 } 679 }
680 .intern(self.def_collector.db); 680 .intern(self.def_collector.db);
681 681
682 PerNs::values(f.into()) 682 PerNs::values(def.into())
683 } 683 }
684 raw::DefKind::Struct(ast_id) => { 684 raw::DefKind::Struct(ast_id) => {
685 let id = StructOrUnionId::from_ast_id(ctx, ast_id).into(); 685 let id = StructOrUnionId::from_ast_id(ctx, ast_id).into();
@@ -692,13 +692,27 @@ where
692 PerNs::both(u, u) 692 PerNs::both(u, u)
693 } 693 }
694 raw::DefKind::Enum(ast_id) => PerNs::types(EnumId::from_ast_id(ctx, ast_id).into()), 694 raw::DefKind::Enum(ast_id) => PerNs::types(EnumId::from_ast_id(ctx, ast_id).into()),
695 raw::DefKind::Const(ast_id) => PerNs::values(ConstId::from_ast_id(ctx, ast_id).into()), 695 raw::DefKind::Const(ast_id) => {
696 let def = ConstLoc {
697 container: ContainerId::ModuleId(module),
698 ast_id: AstId::new(self.file_id, ast_id),
699 }
700 .intern(self.def_collector.db);
701
702 PerNs::values(def.into())
703 }
696 raw::DefKind::Static(ast_id) => { 704 raw::DefKind::Static(ast_id) => {
697 PerNs::values(StaticId::from_ast_id(ctx, ast_id).into()) 705 PerNs::values(StaticId::from_ast_id(ctx, ast_id).into())
698 } 706 }
699 raw::DefKind::Trait(ast_id) => PerNs::types(TraitId::from_ast_id(ctx, ast_id).into()), 707 raw::DefKind::Trait(ast_id) => PerNs::types(TraitId::from_ast_id(ctx, ast_id).into()),
700 raw::DefKind::TypeAlias(ast_id) => { 708 raw::DefKind::TypeAlias(ast_id) => {
701 PerNs::types(TypeAliasId::from_ast_id(ctx, ast_id).into()) 709 let def = TypeAliasLoc {
710 container: ContainerId::ModuleId(module),
711 ast_id: AstId::new(self.file_id, ast_id),
712 }
713 .intern(self.def_collector.db);
714
715 PerNs::types(def.into())
702 } 716 }
703 }; 717 };
704 let resolution = Resolution { def, import: None }; 718 let resolution = Resolution { def, import: None };