aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-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)]