aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs19
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
20impl HirInterner { 21impl HirInterner {
@@ -213,6 +214,24 @@ impl StructLoc {
213 } 214 }
214} 215}
215 216
217#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
218pub struct EnumId(RawId);
219impl_arena_id!(EnumId);
220
221pub(crate) type EnumLoc = ItemLoc<ast::EnumDef>;
222
223impl EnumId {
224 pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> EnumLoc {
225 db.as_ref().enums.id2loc(self)
226 }
227}
228
229impl 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)]