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.rs23
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::{
11pub struct HirInterner { 11pub 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
16impl HirInterner { 17impl HirInterner {
@@ -128,6 +129,28 @@ impl MacroCallLoc {
128 } 129 }
129} 130}
130 131
132#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
133pub struct FunctionId(RawId);
134impl_arena_id!(FunctionId);
135
136#[derive(Clone, Debug, PartialEq, Eq, Hash)]
137pub struct FunctionLoc {
138 pub(crate) module: Module,
139 pub(crate) source_item_id: SourceItemId,
140}
141
142impl FunctionId {
143 pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> FunctionLoc {
144 db.as_ref().fns.id2loc(self)
145 }
146}
147
148impl 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)]