aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r--crates/ra_analysis/src/loc2id.rs25
1 files changed, 17 insertions, 8 deletions
diff --git a/crates/ra_analysis/src/loc2id.rs b/crates/ra_analysis/src/loc2id.rs
index 8eaa24997..53bf609fa 100644
--- a/crates/ra_analysis/src/loc2id.rs
+++ b/crates/ra_analysis/src/loc2id.rs
@@ -72,17 +72,26 @@ 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);
90impl_numeric_id!(FnId);
77 91
78impl NumericId for FnId { 92#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
79 fn from_u32(id: u32) -> FnId { 93pub(crate) struct ModId(u32);
80 FnId(id) 94impl_numeric_id!(ModId);
81 }
82 fn to_u32(self) -> u32 {
83 self.0
84 }
85}
86 95
87pub(crate) trait IdDatabase: salsa::Database { 96pub(crate) trait IdDatabase: salsa::Database {
88 fn id_maps(&self) -> &IdMaps; 97 fn id_maps(&self) -> &IdMaps;