aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-24 11:13:51 +0000
committerAleksey Kladov <[email protected]>2019-11-24 11:13:51 +0000
commit53506a755220557a558be4da244b70d79f5b0fa9 (patch)
tree0781995393812f583200929cea61c706290ee137 /crates
parentf11237561c391eecba39c5ba57defa2dc7a27b21 (diff)
Pull macro up
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_db/src/lib.rs14
-rw-r--r--crates/ra_hir/src/ids.rs15
-rw-r--r--crates/ra_hir_def/src/lib.rs15
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::{
15pub use relative_path::{RelativePath, RelativePathBuf}; 15pub use relative_path::{RelativePath, RelativePathBuf};
16pub use salsa; 16pub use salsa;
17 17
18#[macro_export]
19macro_rules! impl_intern_key {
20 ($name:ident) => {
21 impl $crate::salsa::InternKey for $name {
22 fn from_intern_id(v: $crate::salsa::InternId) -> Self {
23 $name(v)
24 }
25 fn as_intern_id(&self) -> $crate::salsa::InternId {
26 self.0
27 }
28 }
29 };
30}
31
18pub trait CheckCanceled { 32pub trait CheckCanceled {
19 /// Aborts current query if there are pending changes. 33 /// Aborts current query if there are pending changes.
20 /// 34 ///
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 @@
5//! This module defines a bunch of ids we are using. The most important ones are 5//! This module defines a bunch of ids we are using. The most important ones are
6//! probably `HirFileId` and `DefId`. 6//! probably `HirFileId` and `DefId`.
7 7
8use ra_db::salsa; 8use ra_db::{impl_intern_key, salsa};
9
10macro_rules! impl_intern_key {
11 ($name:ident) => {
12 impl salsa::InternKey for $name {
13 fn from_intern_id(v: salsa::InternId) -> Self {
14 $name(v)
15 }
16 fn as_intern_id(&self) -> salsa::InternId {
17 self.0
18 }
19 }
20 };
21}
22 9
23/// This exists just for Chalk, because Chalk just has a single `StructId` where 10/// This exists just for Chalk, because Chalk just has a single `StructId` where
24/// we have different kinds of ADTs, primitive types and special type 11/// 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};
35 35
36use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, MacroDefId, Source}; 36use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, MacroDefId, Source};
37use ra_arena::{impl_arena_id, map::ArenaMap, RawId}; 37use ra_arena::{impl_arena_id, map::ArenaMap, RawId};
38use ra_db::{salsa, CrateId}; 38use ra_db::{impl_intern_key, salsa, CrateId};
39use ra_syntax::{ast, AstNode}; 39use ra_syntax::{ast, AstNode};
40 40
41use crate::{builtin_type::BuiltinType, db::InternDatabase}; 41use crate::{builtin_type::BuiltinType, db::InternDatabase};
@@ -56,19 +56,6 @@ pub struct ModuleId {
56pub struct LocalModuleId(RawId); 56pub struct LocalModuleId(RawId);
57impl_arena_id!(LocalModuleId); 57impl_arena_id!(LocalModuleId);
58 58
59macro_rules! impl_intern_key {
60 ($name:ident) => {
61 impl salsa::InternKey for $name {
62 fn from_intern_id(v: salsa::InternId) -> Self {
63 $name(v)
64 }
65 fn as_intern_id(&self) -> salsa::InternId {
66 self.0
67 }
68 }
69 };
70}
71
72#[derive(Debug)] 59#[derive(Debug)]
73pub struct ItemLoc<N: AstNode> { 60pub struct ItemLoc<N: AstNode> {
74 pub(crate) module: ModuleId, 61 pub(crate) module: ModuleId,