diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 81 |
1 files changed, 33 insertions, 48 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 2b194f488..b4e438257 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -714,12 +714,9 @@ where | |||
714 | modules[res].scope.define_legacy_macro(name, mac) | 714 | modules[res].scope.define_legacy_macro(name, mac) |
715 | } | 715 | } |
716 | modules[self.module_id].children.insert(name.clone(), res); | 716 | modules[self.module_id].children.insert(name.clone(), res); |
717 | let resolution = Resolution { | 717 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; |
718 | def: PerNs::types( | 718 | let def: ModuleDefId = module.into(); |
719 | ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(), | 719 | let resolution = Resolution { def: def.into(), import: false }; |
720 | ), | ||
721 | import: false, | ||
722 | }; | ||
723 | self.def_collector.update(self.module_id, None, &[(name, resolution)]); | 720 | self.def_collector.update(self.module_id, None, &[(name, resolution)]); |
724 | res | 721 | res |
725 | } | 722 | } |
@@ -734,63 +731,51 @@ where | |||
734 | 731 | ||
735 | let name = def.name.clone(); | 732 | let name = def.name.clone(); |
736 | let container = ContainerId::ModuleId(module); | 733 | let container = ContainerId::ModuleId(module); |
737 | let def: PerNs = match def.kind { | 734 | let def: ModuleDefId = match def.kind { |
738 | raw::DefKind::Function(ast_id) => { | 735 | raw::DefKind::Function(ast_id) => FunctionLoc { |
739 | let def = FunctionLoc { | 736 | container: container.into(), |
740 | container: container.into(), | 737 | ast_id: AstId::new(self.file_id, ast_id), |
741 | ast_id: AstId::new(self.file_id, ast_id), | ||
742 | } | ||
743 | .intern(self.def_collector.db); | ||
744 | |||
745 | PerNs::values(def.into()) | ||
746 | } | 738 | } |
739 | .intern(self.def_collector.db) | ||
740 | .into(), | ||
747 | raw::DefKind::Struct(ast_id) => { | 741 | raw::DefKind::Struct(ast_id) => { |
748 | let def = StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } | 742 | StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
749 | .intern(self.def_collector.db); | 743 | .intern(self.def_collector.db) |
750 | PerNs::both(def.into(), def.into()) | 744 | .into() |
751 | } | 745 | } |
752 | raw::DefKind::Union(ast_id) => { | 746 | raw::DefKind::Union(ast_id) => { |
753 | let def = UnionLoc { container, ast_id: AstId::new(self.file_id, ast_id) } | 747 | UnionLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
754 | .intern(self.def_collector.db); | 748 | .intern(self.def_collector.db) |
755 | PerNs::both(def.into(), def.into()) | 749 | .into() |
756 | } | 750 | } |
757 | raw::DefKind::Enum(ast_id) => { | 751 | raw::DefKind::Enum(ast_id) => { |
758 | let def = EnumLoc { container, ast_id: AstId::new(self.file_id, ast_id) } | 752 | EnumLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
759 | .intern(self.def_collector.db); | 753 | .intern(self.def_collector.db) |
760 | PerNs::types(def.into()) | 754 | .into() |
761 | } | 755 | } |
762 | raw::DefKind::Const(ast_id) => { | 756 | raw::DefKind::Const(ast_id) => { |
763 | let def = ConstLoc { | 757 | ConstLoc { container: container.into(), ast_id: AstId::new(self.file_id, ast_id) } |
764 | container: container.into(), | 758 | .intern(self.def_collector.db) |
765 | ast_id: AstId::new(self.file_id, ast_id), | 759 | .into() |
766 | } | ||
767 | .intern(self.def_collector.db); | ||
768 | |||
769 | PerNs::values(def.into()) | ||
770 | } | 760 | } |
771 | raw::DefKind::Static(ast_id) => { | 761 | raw::DefKind::Static(ast_id) => { |
772 | let def = StaticLoc { container, ast_id: AstId::new(self.file_id, ast_id) } | 762 | StaticLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
773 | .intern(self.def_collector.db); | 763 | .intern(self.def_collector.db) |
774 | 764 | .into() | |
775 | PerNs::values(def.into()) | ||
776 | } | 765 | } |
777 | raw::DefKind::Trait(ast_id) => { | 766 | raw::DefKind::Trait(ast_id) => { |
778 | let def = TraitLoc { container, ast_id: AstId::new(self.file_id, ast_id) } | 767 | TraitLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
779 | .intern(self.def_collector.db); | 768 | .intern(self.def_collector.db) |
780 | 769 | .into() | |
781 | PerNs::types(def.into()) | ||
782 | } | 770 | } |
783 | raw::DefKind::TypeAlias(ast_id) => { | 771 | raw::DefKind::TypeAlias(ast_id) => TypeAliasLoc { |
784 | let def = TypeAliasLoc { | 772 | container: container.into(), |
785 | container: container.into(), | 773 | ast_id: AstId::new(self.file_id, ast_id), |
786 | ast_id: AstId::new(self.file_id, ast_id), | ||
787 | } | ||
788 | .intern(self.def_collector.db); | ||
789 | |||
790 | PerNs::types(def.into()) | ||
791 | } | 774 | } |
775 | .intern(self.def_collector.db) | ||
776 | .into(), | ||
792 | }; | 777 | }; |
793 | let resolution = Resolution { def, import: false }; | 778 | let resolution = Resolution { def: def.into(), import: false }; |
794 | self.def_collector.update(self.module_id, None, &[(name, resolution)]) | 779 | self.def_collector.update(self.module_id, None, &[(name, resolution)]) |
795 | } | 780 | } |
796 | 781 | ||