Remove ty from code_model

This commit is contained in:
Aleksey Kladov 2019-12-08 12:44:14 +01:00
parent b77d7c24aa
commit b37c6a746b
9 changed files with 53 additions and 55 deletions

View file

@ -9,16 +9,10 @@ use hir_def::{
};
use crate::{
Adt, AssocItem, AttrDef, Crate, DefWithBody, EnumVariant, GenericDef, ModuleDef, StructField,
Adt, AssocItem, AttrDef, DefWithBody, EnumVariant, GenericDef, ModuleDef, StructField,
VariantDef,
};
impl From<ra_db::CrateId> for Crate {
fn from(id: ra_db::CrateId) -> Self {
Crate { id }
}
}
macro_rules! from_id {
($(($id:path, $ty:path)),*) => {$(
impl From<$id> for $ty {
@ -26,10 +20,16 @@ macro_rules! from_id {
$ty { id }
}
}
impl From<$ty> for $id {
fn from(ty: $ty) -> $id {
ty.id
}
}
)*}
}
from_id![
(ra_db::CrateId, crate::Crate),
(hir_def::ModuleId, crate::Module),
(hir_def::StructId, crate::Struct),
(hir_def::UnionId, crate::Union),