From 8f1f5a783a3ffd0afbf5b1fdf22ff9caf7fda928 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 28 Nov 2019 18:05:28 +0300 Subject: Move source-related traits to a separate module --- crates/ra_hir_def/src/lib.rs | 54 +++----------------------------------------- 1 file changed, 3 insertions(+), 51 deletions(-) (limited to 'crates/ra_hir_def/src/lib.rs') diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 6daf7d3a3..cfeacfded 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -29,6 +29,8 @@ pub mod resolver; mod trace; pub mod nameres; +pub mod src; + #[cfg(test)] mod test_db; #[cfg(test)] @@ -37,7 +39,7 @@ mod marks; use std::hash::{Hash, Hasher}; use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, InFile, MacroDefId}; -use ra_arena::{impl_arena_id, map::ArenaMap, RawId}; +use ra_arena::{impl_arena_id, RawId}; use ra_db::{impl_intern_key, salsa, CrateId}; use ra_syntax::{ast, AstNode}; @@ -514,53 +516,3 @@ impl HasModule for StaticLoc { self.container } } - -pub trait HasSource { - type Value; - fn source(&self, db: &impl db::DefDatabase) -> InFile; -} - -impl HasSource for FunctionLoc { - type Value = ast::FnDef; - - fn source(&self, db: &impl db::DefDatabase) -> InFile { - let node = self.ast_id.to_node(db); - InFile::new(self.ast_id.file_id, node) - } -} - -impl HasSource for TypeAliasLoc { - type Value = ast::TypeAliasDef; - - fn source(&self, db: &impl db::DefDatabase) -> InFile { - let node = self.ast_id.to_node(db); - InFile::new(self.ast_id.file_id, node) - } -} - -impl HasSource for ConstLoc { - type Value = ast::ConstDef; - - fn source(&self, db: &impl db::DefDatabase) -> InFile { - let node = self.ast_id.to_node(db); - InFile::new(self.ast_id.file_id, node) - } -} - -impl HasSource for StaticLoc { - type Value = ast::StaticDef; - - fn source(&self, db: &impl db::DefDatabase) -> InFile { - let node = self.ast_id.to_node(db); - InFile::new(self.ast_id.file_id, node) - } -} - -pub trait HasChildSource { - type ChildId; - type Value; - fn child_source( - &self, - db: &impl db::DefDatabase, - ) -> InFile>; -} -- cgit v1.2.3