diff options
author | Aleksey Kladov <[email protected]> | 2019-01-24 13:18:20 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-24 13:18:20 +0000 |
commit | c57a8579888643e73e12dd0ca23e81f88608c52f (patch) | |
tree | b2f3dc5fdcdeb93b0c9c20e13cb966f596a1e006 /crates/ra_hir | |
parent | 2734636c532101565b1a4c4715790d4cc910ad47 (diff) |
add StructId
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/ids.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index f00448081..51e3cfb81 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -14,6 +14,7 @@ pub struct HirInterner { | |||
14 | defs: LocationIntener<DefLoc, DefId>, | 14 | defs: LocationIntener<DefLoc, DefId>, |
15 | macros: LocationIntener<MacroCallLoc, MacroCallId>, | 15 | macros: LocationIntener<MacroCallLoc, MacroCallId>, |
16 | fns: LocationIntener<FunctionLoc, FunctionId>, | 16 | fns: LocationIntener<FunctionLoc, FunctionId>, |
17 | structs: LocationIntener<StructLoc, StructId>, | ||
17 | } | 18 | } |
18 | 19 | ||
19 | impl HirInterner { | 20 | impl HirInterner { |
@@ -194,6 +195,24 @@ impl FunctionLoc { | |||
194 | } | 195 | } |
195 | } | 196 | } |
196 | 197 | ||
198 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
199 | pub struct StructId(RawId); | ||
200 | impl_arena_id!(StructId); | ||
201 | |||
202 | pub(crate) type StructLoc = ItemLoc<ast::StructDef>; | ||
203 | |||
204 | impl StructId { | ||
205 | pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> StructLoc { | ||
206 | db.as_ref().structs.id2loc(self) | ||
207 | } | ||
208 | } | ||
209 | |||
210 | impl StructLoc { | ||
211 | pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> StructId { | ||
212 | db.as_ref().structs.loc2id(&self) | ||
213 | } | ||
214 | } | ||
215 | |||
197 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) | 216 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) |
198 | /// in a specific module. | 217 | /// in a specific module. |
199 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 218 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |