From 56710f119b7114efac237ac36ea21730b8bd5311 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 12 Dec 2019 15:11:57 +0100 Subject: Move enum&union to new loc --- crates/ra_hir_def/src/nameres/collector.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir_def/src/nameres/collector.rs') diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 602ec0911..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::{ }, path::{Path, PathKind}, per_ns::PerNs, - AdtId, AstId, AstItemDef, ConstLoc, ContainerId, EnumId, EnumVariantId, FunctionLoc, ImplLoc, - Intern, LocalImportId, LocalModuleId, LocationCtx, ModuleDefId, ModuleId, StaticLoc, StructLoc, - TraitLoc, TypeAliasLoc, UnionId, + AdtId, AstId, ConstLoc, ContainerId, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern, + LocalImportId, LocalModuleId, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitLoc, + TypeAliasLoc, UnionLoc, }; pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { @@ -753,8 +753,6 @@ where fn define_def(&mut self, def: &raw::DefData, attrs: &Attrs) { let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: self.module_id }; - let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); - // FIXME: check attrs to see if this is an attribute macro invocation; // in which case we don't add the invocation, just a single attribute // macro invocation @@ -778,10 +776,15 @@ where PerNs::both(def.into(), def.into()) } raw::DefKind::Union(ast_id) => { - let id = UnionId::from_ast_id(ctx, ast_id).into(); - PerNs::both(id, id) + let def = UnionLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } + .intern(self.def_collector.db); + PerNs::both(def.into(), def.into()) + } + raw::DefKind::Enum(ast_id) => { + let def = EnumLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } + .intern(self.def_collector.db); + PerNs::types(def.into()) } - raw::DefKind::Enum(ast_id) => PerNs::types(EnumId::from_ast_id(ctx, ast_id).into()), raw::DefKind::Const(ast_id) => { let def = ConstLoc { container: ContainerId::ModuleId(module), -- cgit v1.2.3