From 53506a755220557a558be4da244b70d79f5b0fa9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Nov 2019 14:13:51 +0300 Subject: Pull macro up --- crates/ra_db/src/lib.rs | 14 ++++++++++++++ crates/ra_hir/src/ids.rs | 15 +-------------- crates/ra_hir_def/src/lib.rs | 15 +-------------- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index f9d012cb0..e8852531b 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -15,6 +15,20 @@ pub use crate::{ pub use relative_path::{RelativePath, RelativePathBuf}; pub use salsa; +#[macro_export] +macro_rules! impl_intern_key { + ($name:ident) => { + impl $crate::salsa::InternKey for $name { + fn from_intern_id(v: $crate::salsa::InternId) -> Self { + $name(v) + } + fn as_intern_id(&self) -> $crate::salsa::InternId { + self.0 + } + } + }; +} + pub trait CheckCanceled { /// Aborts current query if there are pending changes. /// diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 145837f7f..67de8b243 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -5,20 +5,7 @@ //! This module defines a bunch of ids we are using. The most important ones are //! probably `HirFileId` and `DefId`. -use ra_db::salsa; - -macro_rules! impl_intern_key { - ($name:ident) => { - impl salsa::InternKey for $name { - fn from_intern_id(v: salsa::InternId) -> Self { - $name(v) - } - fn as_intern_id(&self) -> salsa::InternId { - self.0 - } - } - }; -} +use ra_db::{impl_intern_key, salsa}; /// This exists just for Chalk, because Chalk just has a single `StructId` where /// we have different kinds of ADTs, primitive types and special type diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 1d195d65d..b063530c2 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -35,7 +35,7 @@ use std::hash::{Hash, Hasher}; use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, MacroDefId, Source}; use ra_arena::{impl_arena_id, map::ArenaMap, RawId}; -use ra_db::{salsa, CrateId}; +use ra_db::{impl_intern_key, salsa, CrateId}; use ra_syntax::{ast, AstNode}; use crate::{builtin_type::BuiltinType, db::InternDatabase}; @@ -56,19 +56,6 @@ pub struct ModuleId { pub struct LocalModuleId(RawId); impl_arena_id!(LocalModuleId); -macro_rules! impl_intern_key { - ($name:ident) => { - impl salsa::InternKey for $name { - fn from_intern_id(v: salsa::InternId) -> Self { - $name(v) - } - fn as_intern_id(&self) -> salsa::InternId { - self.0 - } - } - }; -} - #[derive(Debug)] pub struct ItemLoc { pub(crate) module: ModuleId, -- cgit v1.2.3