aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-24 14:56:00 +0000
committerAleksey Kladov <[email protected]>2019-01-24 14:56:00 +0000
commitcefc5cbb4a95d2a473ea656efe603bef979b5c49 (patch)
tree45f91a3398eeeca19a2e4c14dca737dc0a5b38a4
parent60a607d33f1c50acd0a4218da32abe35b2941e38 (diff)
introduce EnumId
-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)]