Move body queries to hir_def

This commit is contained in:
Aleksey Kladov 2019-11-14 17:37:22 +03:00
parent ef02296b9f
commit 1583ab1558
12 changed files with 110 additions and 75 deletions

View file

@ -3,9 +3,9 @@
//! It's unclear if we need this long-term, but it's definitelly useful while we
//! are splitting the hir.
use hir_def::{AdtId, EnumVariantId, ModuleDefId};
use hir_def::{AdtId, DefWithBodyId, EnumVariantId, ModuleDefId};
use crate::{Adt, EnumVariant, ModuleDef};
use crate::{Adt, DefWithBody, EnumVariant, ModuleDef};
macro_rules! from_id {
($(($id:path, $ty:path)),*) => {$(
@ -61,3 +61,13 @@ impl From<ModuleDefId> for ModuleDef {
}
}
}
impl From<DefWithBody> for DefWithBodyId {
fn from(def: DefWithBody) -> Self {
match def {
DefWithBody::Function(it) => DefWithBodyId::FunctionId(it.id),
DefWithBody::Static(it) => DefWithBodyId::StaticId(it.id),
DefWithBody::Const(it) => DefWithBodyId::ConstId(it.id),
}
}
}