diff options
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r-- | crates/ra_analysis/src/loc2id.rs | 25 |
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 | ||
75 | macro_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)] |
76 | pub(crate) struct FnId(u32); | 89 | pub(crate) struct FnId(u32); |
90 | impl_numeric_id!(FnId); | ||
77 | 91 | ||
78 | impl NumericId for FnId { | 92 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
79 | fn from_u32(id: u32) -> FnId { | 93 | pub(crate) struct ModId(u32); |
80 | FnId(id) | 94 | impl_numeric_id!(ModId); |
81 | } | ||
82 | fn to_u32(self) -> u32 { | ||
83 | self.0 | ||
84 | } | ||
85 | } | ||
86 | 95 | ||
87 | pub(crate) trait IdDatabase: salsa::Database { | 96 | pub(crate) trait IdDatabase: salsa::Database { |
88 | fn id_maps(&self) -> &IdMaps; | 97 | fn id_maps(&self) -> &IdMaps; |