diff options
-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 2791149dd..530fdf5cd 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -15,6 +15,7 @@ pub struct HirInterner { | |||
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 | structs: LocationIntener<StructLoc, StructId>, |
18 | enums: LocationIntener<EnumLoc, EnumId>, | ||
18 | } | 19 | } |
19 | 20 | ||
20 | impl HirInterner { | 21 | impl HirInterner { |
@@ -213,6 +214,24 @@ impl StructLoc { | |||
213 | } | 214 | } |
214 | } | 215 | } |
215 | 216 | ||
217 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
218 | pub struct EnumId(RawId); | ||
219 | impl_arena_id!(EnumId); | ||
220 | |||
221 | pub(crate) type EnumLoc = ItemLoc<ast::EnumDef>; | ||
222 | |||
223 | impl EnumId { | ||
224 | pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> EnumLoc { | ||
225 | db.as_ref().enums.id2loc(self) | ||
226 | } | ||
227 | } | ||
228 | |||
229 | impl EnumLoc { | ||
230 | pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> EnumId { | ||
231 | db.as_ref().enums.loc2id(&self) | ||
232 | } | ||
233 | } | ||
234 | |||
216 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) | 235 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) |
217 | /// in a specific module. | 236 | /// in a specific module. |
218 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 237 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |