diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index f00448081c..51e3cfb813 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -14,6 +14,7 @@ pub struct HirInterner { defs: LocationIntener, macros: LocationIntener, fns: LocationIntener, + structs: LocationIntener, } impl HirInterner { @@ -194,6 +195,24 @@ impl FunctionLoc { } } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct StructId(RawId); +impl_arena_id!(StructId); + +pub(crate) type StructLoc = ItemLoc; + +impl StructId { + pub(crate) fn loc(self, db: &impl AsRef) -> StructLoc { + db.as_ref().structs.id2loc(self) + } +} + +impl StructLoc { + pub(crate) fn id(&self, db: &impl AsRef) -> StructId { + db.as_ref().structs.loc2id(&self) + } +} + /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) /// in a specific module. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]