aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-24 13:18:20 +0000
committerAleksey Kladov <[email protected]>2019-01-24 13:18:20 +0000
commitc57a8579888643e73e12dd0ca23e81f88608c52f (patch)
treeb2f3dc5fdcdeb93b0c9c20e13cb966f596a1e006 /crates/ra_hir
parent2734636c532101565b1a4c4715790d4cc910ad47 (diff)
add StructId
Diffstat (limited to 'crates/ra_hir')
-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 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
19impl HirInterner { 20impl HirInterner {
@@ -194,6 +195,24 @@ impl FunctionLoc {
194 } 195 }
195} 196}
196 197
198#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
199pub struct StructId(RawId);
200impl_arena_id!(StructId);
201
202pub(crate) type StructLoc = ItemLoc<ast::StructDef>;
203
204impl StructId {
205 pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> StructLoc {
206 db.as_ref().structs.id2loc(self)
207 }
208}
209
210impl 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)]