aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/loc2id.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-11-20 14:33:54 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-11-20 14:33:54 +0000
commit713c3ea30b38199e05e1f70094d85177f16915f8 (patch)
treef4f3c59a59e4a607b77321cb685bf616824dc8f7 /crates/ra_analysis/src/loc2id.rs
parent902778ccaefc7b51548cab459715aaf8653bbbc6 (diff)
parenta2fdb41ace4de7737a3ba0e4ef5e68d0a41e924d (diff)
Merge #234
234: Global module r=matklad a=matklad This series of commits re-introdces `ModuleDescriptor` as one stop shop for all information about a module. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/loc2id.rs')
-rw-r--r--crates/ra_analysis/src/loc2id.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/crates/ra_analysis/src/loc2id.rs b/crates/ra_analysis/src/loc2id.rs
index 8eaa24997..8c297156a 100644
--- a/crates/ra_analysis/src/loc2id.rs
+++ b/crates/ra_analysis/src/loc2id.rs
@@ -72,17 +72,22 @@ pub(crate) trait NumericId: Clone + Eq + Hash {
72 fn to_u32(self) -> u32; 72 fn to_u32(self) -> u32;
73} 73}
74 74
75macro_rules! impl_numeric_id {
76 ($id:ident) => {
77 impl NumericId for $id {
78 fn from_u32(id: u32) -> Self {
79 $id(id)
80 }
81 fn to_u32(self) -> u32 {
82 self.0
83 }
84 }
85 };
86}
87
75#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 88#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
76pub(crate) struct FnId(u32); 89pub(crate) struct FnId(u32);
77 90impl_numeric_id!(FnId);
78impl NumericId for FnId {
79 fn from_u32(id: u32) -> FnId {
80 FnId(id)
81 }
82 fn to_u32(self) -> u32 {
83 self.0
84 }
85}
86 91
87pub(crate) trait IdDatabase: salsa::Database { 92pub(crate) trait IdDatabase: salsa::Database {
88 fn id_maps(&self) -> &IdMaps; 93 fn id_maps(&self) -> &IdMaps;