add FunctionId
This commit is contained in:
parent
3ab1519cb2
commit
f1959bbae0
@ -11,6 +11,7 @@ use crate::{
|
||||
pub struct HirInterner {
|
||||
defs: LocationIntener<DefLoc, DefId>,
|
||||
macros: LocationIntener<MacroCallLoc, MacroCallId>,
|
||||
fns: LocationIntener<FunctionLoc, FunctionId>,
|
||||
}
|
||||
|
||||
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)
|
||||
/// in a specific module.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user