add FunctionId
This commit is contained in:
@@ -11,6 +11,7 @@ use crate::{
|
|||||||
pub struct HirInterner {
|
pub struct HirInterner {
|
||||||
defs: LocationIntener<DefLoc, DefId>,
|
defs: LocationIntener<DefLoc, DefId>,
|
||||||
macros: LocationIntener<MacroCallLoc, MacroCallId>,
|
macros: LocationIntener<MacroCallLoc, MacroCallId>,
|
||||||
|
fns: LocationIntener<FunctionLoc, FunctionId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HirInterner {
|
impl HirInterner {
|
||||||
@@ -128,6 +129,28 @@ impl MacroCallLoc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub struct FunctionId(RawId);
|
||||||
|
impl_arena_id!(FunctionId);
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
|
pub struct FunctionLoc {
|
||||||
|
pub(crate) module: Module,
|
||||||
|
pub(crate) source_item_id: SourceItemId,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FunctionId {
|
||||||
|
pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> FunctionLoc {
|
||||||
|
db.as_ref().fns.id2loc(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FunctionLoc {
|
||||||
|
pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> FunctionId {
|
||||||
|
db.as_ref().fns.loc2id(&self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Def's are a core concept of hir. A `Def` is an Item (function, module, etc)
|
/// Def's are a core concept of hir. A `Def` is an Item (function, module, etc)
|
||||||
/// in a specific module.
|
/// in a specific module.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
|||||||
Reference in New Issue
Block a user