diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-20 14:33:54 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-20 14:33:54 +0000 |
commit | 713c3ea30b38199e05e1f70094d85177f16915f8 (patch) | |
tree | f4f3c59a59e4a607b77321cb685bf616824dc8f7 /crates/ra_analysis/src/loc2id.rs | |
parent | 902778ccaefc7b51548cab459715aaf8653bbbc6 (diff) | |
parent | a2fdb41ace4de7737a3ba0e4ef5e68d0a41e924d (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.rs | 23 |
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 | ||
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); |
77 | 90 | impl_numeric_id!(FnId); | |
78 | impl 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 | ||
87 | pub(crate) trait IdDatabase: salsa::Database { | 92 | pub(crate) trait IdDatabase: salsa::Database { |
88 | fn id_maps(&self) -> &IdMaps; | 93 | fn id_maps(&self) -> &IdMaps; |