From a03c109f50a01d646cd2e63c190b0bb08760dcd8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 25 Jan 2019 01:41:36 +0300 Subject: Kill DefId --- crates/ra_hir/src/ids.rs | 40 ++++++++++------------------------------ crates/ra_hir/src/lib.rs | 2 +- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index cbe31f830..b125a1518 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -8,13 +8,12 @@ use ra_syntax::{TreeArc, SyntaxNode, SourceFile, AstNode, ast}; use ra_arena::{Arena, RawId, ArenaId, impl_arena_id}; use crate::{ - HirDatabase, Def, + HirDatabase, Module, }; #[derive(Debug, Default)] pub struct HirInterner { - defs: LocationIntener, macros: LocationIntener, fns: LocationIntener, FunctionId>, structs: LocationIntener, StructId>, @@ -28,7 +27,15 @@ pub struct HirInterner { impl HirInterner { pub fn len(&self) -> usize { - self.defs.len() + self.macros.len() + self.macros.len() + + self.fns.len() + + self.structs.len() + + self.enums.len() + + self.enum_variants.len() + + self.consts.len() + + self.statics.len() + + self.traits.len() + + self.types.len() } } @@ -299,33 +306,6 @@ impl AstItemDef for TypeId { } } -/// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) -/// in a specific module. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub struct DefId(RawId); -impl_arena_id!(DefId); - -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub struct DefLoc { - pub(crate) kind: DefKind, - pub(crate) module: Module, - pub(crate) source_item_id: SourceItemId, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub(crate) enum DefKind {} - -impl DefId { - pub(crate) fn loc(self, db: &impl AsRef) -> DefLoc { - db.as_ref().defs.id2loc(self) - } - - pub fn resolve(self, db: &impl HirDatabase) -> Def { - let loc = self.loc(db); - match loc.kind {} - } -} - /// Identifier of item within a specific file. This is stable over reparses, so /// it's OK to use it as a salsa key/value. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 6cbece95e..644affd44 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -52,7 +52,7 @@ use crate::{ pub use self::{ path::{Path, PathKind}, name::Name, - ids::{HirFileId, DefId, DefLoc, MacroCallId, MacroCallLoc, HirInterner}, + ids::{HirFileId, MacroCallId, MacroCallLoc, HirInterner}, macros::{MacroDef, MacroInput, MacroExpansion}, nameres::{ItemMap, PerNs, Namespace, Resolution}, ty::{Ty, AdtDef}, -- cgit v1.2.3