diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/ids.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 99f04e4ef..73f1379f1 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -11,6 +11,7 @@ use crate::{ | |||
11 | pub struct HirInterner { | 11 | pub struct HirInterner { |
12 | defs: LocationIntener<DefLoc, DefId>, | 12 | defs: LocationIntener<DefLoc, DefId>, |
13 | macros: LocationIntener<MacroCallLoc, MacroCallId>, | 13 | macros: LocationIntener<MacroCallLoc, MacroCallId>, |
14 | fns: LocationIntener<FunctionLoc, FunctionId>, | ||
14 | } | 15 | } |
15 | 16 | ||
16 | impl HirInterner { | 17 | impl HirInterner { |
@@ -128,6 +129,28 @@ impl MacroCallLoc { | |||
128 | } | 129 | } |
129 | } | 130 | } |
130 | 131 | ||
132 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
133 | pub struct FunctionId(RawId); | ||
134 | impl_arena_id!(FunctionId); | ||
135 | |||
136 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] | ||
137 | pub struct FunctionLoc { | ||
138 | pub(crate) module: Module, | ||
139 | pub(crate) source_item_id: SourceItemId, | ||
140 | } | ||
141 | |||
142 | impl FunctionId { | ||
143 | pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> FunctionLoc { | ||
144 | db.as_ref().fns.id2loc(self) | ||
145 | } | ||
146 | } | ||
147 | |||
148 | impl FunctionLoc { | ||
149 | pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> FunctionId { | ||
150 | db.as_ref().fns.loc2id(&self) | ||
151 | } | ||
152 | } | ||
153 | |||
131 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) | 154 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) |
132 | /// in a specific module. | 155 | /// in a specific module. |
133 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 156 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |