diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-12 14:20:02 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-12 14:20:02 +0000 |
commit | c213c3b36b7987504c6c3703b76a637dd0d01355 (patch) | |
tree | 36f9066ab25826f9401216d6ff371954eb9f447c /crates/ra_hir_def/src/nameres | |
parent | d8dba7fbe587ba5fb6cfe939083ccd92c61f5827 (diff) | |
parent | 7a255a2f9381ba5886cacc48c1dd0420a739a55c (diff) |
Merge #2539
2539: Remove old location infra r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index b33507a9a..04aadead1 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -24,9 +24,9 @@ use crate::{ | |||
24 | }, | 24 | }, |
25 | path::{Path, PathKind}, | 25 | path::{Path, PathKind}, |
26 | per_ns::PerNs, | 26 | per_ns::PerNs, |
27 | AdtId, AstId, AstItemDef, ConstLoc, ContainerId, EnumId, EnumVariantId, FunctionLoc, ImplLoc, | 27 | AdtId, AstId, ConstLoc, ContainerId, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern, |
28 | Intern, LocalImportId, LocalModuleId, LocationCtx, ModuleDefId, ModuleId, StaticLoc, StructId, | 28 | LocalImportId, LocalModuleId, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitLoc, |
29 | TraitId, TypeAliasLoc, UnionId, | 29 | TypeAliasLoc, UnionLoc, |
30 | }; | 30 | }; |
31 | 31 | ||
32 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { | 32 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { |
@@ -753,8 +753,6 @@ where | |||
753 | 753 | ||
754 | fn define_def(&mut self, def: &raw::DefData, attrs: &Attrs) { | 754 | fn define_def(&mut self, def: &raw::DefData, attrs: &Attrs) { |
755 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: self.module_id }; | 755 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: self.module_id }; |
756 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); | ||
757 | |||
758 | // FIXME: check attrs to see if this is an attribute macro invocation; | 756 | // FIXME: check attrs to see if this is an attribute macro invocation; |
759 | // in which case we don't add the invocation, just a single attribute | 757 | // in which case we don't add the invocation, just a single attribute |
760 | // macro invocation | 758 | // macro invocation |
@@ -773,14 +771,20 @@ where | |||
773 | PerNs::values(def.into()) | 771 | PerNs::values(def.into()) |
774 | } | 772 | } |
775 | raw::DefKind::Struct(ast_id) => { | 773 | raw::DefKind::Struct(ast_id) => { |
776 | let id = StructId::from_ast_id(ctx, ast_id).into(); | 774 | let def = StructLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } |
777 | PerNs::both(id, id) | 775 | .intern(self.def_collector.db); |
776 | PerNs::both(def.into(), def.into()) | ||
778 | } | 777 | } |
779 | raw::DefKind::Union(ast_id) => { | 778 | raw::DefKind::Union(ast_id) => { |
780 | let id = UnionId::from_ast_id(ctx, ast_id).into(); | 779 | let def = UnionLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } |
781 | PerNs::both(id, id) | 780 | .intern(self.def_collector.db); |
781 | PerNs::both(def.into(), def.into()) | ||
782 | } | ||
783 | raw::DefKind::Enum(ast_id) => { | ||
784 | let def = EnumLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | ||
785 | .intern(self.def_collector.db); | ||
786 | PerNs::types(def.into()) | ||
782 | } | 787 | } |
783 | raw::DefKind::Enum(ast_id) => PerNs::types(EnumId::from_ast_id(ctx, ast_id).into()), | ||
784 | raw::DefKind::Const(ast_id) => { | 788 | raw::DefKind::Const(ast_id) => { |
785 | let def = ConstLoc { | 789 | let def = ConstLoc { |
786 | container: ContainerId::ModuleId(module), | 790 | container: ContainerId::ModuleId(module), |
@@ -796,7 +800,12 @@ where | |||
796 | 800 | ||
797 | PerNs::values(def.into()) | 801 | PerNs::values(def.into()) |
798 | } | 802 | } |
799 | raw::DefKind::Trait(ast_id) => PerNs::types(TraitId::from_ast_id(ctx, ast_id).into()), | 803 | raw::DefKind::Trait(ast_id) => { |
804 | let def = TraitLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | ||
805 | .intern(self.def_collector.db); | ||
806 | |||
807 | PerNs::types(def.into()) | ||
808 | } | ||
800 | raw::DefKind::TypeAlias(ast_id) => { | 809 | raw::DefKind::TypeAlias(ast_id) => { |
801 | let def = TypeAliasLoc { | 810 | let def = TypeAliasLoc { |
802 | container: ContainerId::ModuleId(module), | 811 | container: ContainerId::ModuleId(module), |