diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 8bbf7ffa2..e68bf4868 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -661,9 +661,10 @@ where | |||
661 | krate: self.def_collector.def_map.krate, | 661 | krate: self.def_collector.def_map.krate, |
662 | local_id: self.module_id, | 662 | local_id: self.module_id, |
663 | }; | 663 | }; |
664 | let container = ContainerId::ModuleId(module); | ||
664 | let ast_id = self.raw_items[imp].ast_id; | 665 | let ast_id = self.raw_items[imp].ast_id; |
665 | let impl_id = | 666 | let impl_id = |
666 | ImplLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 667 | ImplLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
667 | .intern(self.def_collector.db); | 668 | .intern(self.def_collector.db); |
668 | self.def_collector.def_map.modules[self.module_id].impls.push(impl_id) | 669 | self.def_collector.def_map.modules[self.module_id].impls.push(impl_id) |
669 | } | 670 | } |
@@ -760,10 +761,11 @@ where | |||
760 | self.collect_derives(attrs, def); | 761 | self.collect_derives(attrs, def); |
761 | 762 | ||
762 | let name = def.name.clone(); | 763 | let name = def.name.clone(); |
764 | let container = ContainerId::ModuleId(module); | ||
763 | let def: PerNs = match def.kind { | 765 | let def: PerNs = match def.kind { |
764 | raw::DefKind::Function(ast_id) => { | 766 | raw::DefKind::Function(ast_id) => { |
765 | let def = FunctionLoc { | 767 | let def = FunctionLoc { |
766 | container: ContainerId::ModuleId(module), | 768 | container: container.into(), |
767 | ast_id: AstId::new(self.file_id, ast_id), | 769 | ast_id: AstId::new(self.file_id, ast_id), |
768 | } | 770 | } |
769 | .intern(self.def_collector.db); | 771 | .intern(self.def_collector.db); |
@@ -771,23 +773,23 @@ where | |||
771 | PerNs::values(def.into()) | 773 | PerNs::values(def.into()) |
772 | } | 774 | } |
773 | raw::DefKind::Struct(ast_id) => { | 775 | raw::DefKind::Struct(ast_id) => { |
774 | let def = StructLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 776 | let def = StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
775 | .intern(self.def_collector.db); | 777 | .intern(self.def_collector.db); |
776 | PerNs::both(def.into(), def.into()) | 778 | PerNs::both(def.into(), def.into()) |
777 | } | 779 | } |
778 | raw::DefKind::Union(ast_id) => { | 780 | raw::DefKind::Union(ast_id) => { |
779 | let def = UnionLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 781 | let def = UnionLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
780 | .intern(self.def_collector.db); | 782 | .intern(self.def_collector.db); |
781 | PerNs::both(def.into(), def.into()) | 783 | PerNs::both(def.into(), def.into()) |
782 | } | 784 | } |
783 | raw::DefKind::Enum(ast_id) => { | 785 | raw::DefKind::Enum(ast_id) => { |
784 | let def = EnumLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 786 | let def = EnumLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
785 | .intern(self.def_collector.db); | 787 | .intern(self.def_collector.db); |
786 | PerNs::types(def.into()) | 788 | PerNs::types(def.into()) |
787 | } | 789 | } |
788 | raw::DefKind::Const(ast_id) => { | 790 | raw::DefKind::Const(ast_id) => { |
789 | let def = ConstLoc { | 791 | let def = ConstLoc { |
790 | container: ContainerId::ModuleId(module), | 792 | container: container.into(), |
791 | ast_id: AstId::new(self.file_id, ast_id), | 793 | ast_id: AstId::new(self.file_id, ast_id), |
792 | } | 794 | } |
793 | .intern(self.def_collector.db); | 795 | .intern(self.def_collector.db); |
@@ -795,20 +797,20 @@ where | |||
795 | PerNs::values(def.into()) | 797 | PerNs::values(def.into()) |
796 | } | 798 | } |
797 | raw::DefKind::Static(ast_id) => { | 799 | raw::DefKind::Static(ast_id) => { |
798 | let def = StaticLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 800 | let def = StaticLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
799 | .intern(self.def_collector.db); | 801 | .intern(self.def_collector.db); |
800 | 802 | ||
801 | PerNs::values(def.into()) | 803 | PerNs::values(def.into()) |
802 | } | 804 | } |
803 | raw::DefKind::Trait(ast_id) => { | 805 | raw::DefKind::Trait(ast_id) => { |
804 | let def = TraitLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 806 | let def = TraitLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
805 | .intern(self.def_collector.db); | 807 | .intern(self.def_collector.db); |
806 | 808 | ||
807 | PerNs::types(def.into()) | 809 | PerNs::types(def.into()) |
808 | } | 810 | } |
809 | raw::DefKind::TypeAlias(ast_id) => { | 811 | raw::DefKind::TypeAlias(ast_id) => { |
810 | let def = TypeAliasLoc { | 812 | let def = TypeAliasLoc { |
811 | container: ContainerId::ModuleId(module), | 813 | container: container.into(), |
812 | ast_id: AstId::new(self.file_id, ast_id), | 814 | ast_id: AstId::new(self.file_id, ast_id), |
813 | } | 815 | } |
814 | .intern(self.def_collector.db); | 816 | .intern(self.def_collector.db); |