Skip to content

Commit 12501fc

Browse files
committed
Remove TypableDef
1 parent d6e8f27 commit 12501fc

File tree

4 files changed

+7
-98
lines changed

4 files changed

+7
-98
lines changed

crates/ra_hir/src/from_id.rs

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
//! are splitting the hir.
55
66
use hir_def::{
7-
AdtId, AssocItemId, AttrDefId, ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId,
8-
GenericDefId, ModuleDefId, StaticId, StructFieldId, StructId, TypeAliasId, UnionId, VariantId,
7+
AdtId, AssocItemId, AttrDefId, DefWithBodyId, EnumVariantId, GenericDefId, ModuleDefId,
8+
StructFieldId, VariantId,
99
};
1010

1111
use crate::{
12-
ty::TypableDef, Adt, AssocItem, AttrDef, Const, Crate, DefWithBody, EnumVariant, Function,
13-
GenericDef, ModuleDef, Static, StructField, TypeAlias, VariantDef,
12+
Adt, AssocItem, AttrDef, Crate, DefWithBody, EnumVariant, GenericDef, ModuleDef, StructField,
13+
VariantDef,
1414
};
1515

1616
impl From<ra_db::CrateId> for Crate {
@@ -137,58 +137,6 @@ impl From<GenericDef> for GenericDefId {
137137
}
138138
}
139139

140-
impl From<AdtId> for TypableDef {
141-
fn from(id: AdtId) -> Self {
142-
Adt::from(id).into()
143-
}
144-
}
145-
146-
impl From<StructId> for TypableDef {
147-
fn from(id: StructId) -> Self {
148-
AdtId::StructId(id).into()
149-
}
150-
}
151-
152-
impl From<UnionId> for TypableDef {
153-
fn from(id: UnionId) -> Self {
154-
AdtId::UnionId(id).into()
155-
}
156-
}
157-
158-
impl From<EnumId> for TypableDef {
159-
fn from(id: EnumId) -> Self {
160-
AdtId::EnumId(id).into()
161-
}
162-
}
163-
164-
impl From<EnumVariantId> for TypableDef {
165-
fn from(id: EnumVariantId) -> Self {
166-
EnumVariant::from(id).into()
167-
}
168-
}
169-
170-
impl From<TypeAliasId> for TypableDef {
171-
fn from(id: TypeAliasId) -> Self {
172-
TypeAlias::from(id).into()
173-
}
174-
}
175-
176-
impl From<FunctionId> for TypableDef {
177-
fn from(id: FunctionId) -> Self {
178-
Function::from(id).into()
179-
}
180-
}
181-
impl From<ConstId> for TypableDef {
182-
fn from(id: ConstId) -> Self {
183-
Const::from(id).into()
184-
}
185-
}
186-
impl From<StaticId> for TypableDef {
187-
fn from(id: StaticId) -> Self {
188-
Static::from(id).into()
189-
}
190-
}
191-
192140
impl From<Adt> for GenericDefId {
193141
fn from(id: Adt) -> Self {
194142
match id {

crates/ra_hir/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub use lower::CallableDef;
3838
pub(crate) use lower::{
3939
callable_item_sig, field_types_query, generic_defaults_query,
4040
generic_predicates_for_param_query, generic_predicates_query, ty_query, value_ty_query,
41-
TyDefId, TypableDef, ValueTyDefId,
41+
TyDefId, ValueTyDefId,
4242
};
4343
pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
4444

crates/ra_hir/src/ty/lower.rs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ use crate::{
3131
utils::{all_super_traits, associated_type_by_name_including_super_traits, variant_data},
3232
},
3333
util::make_mut_slice,
34-
Adt, Const, Enum, EnumVariant, Function, ImplBlock, ModuleDef, Static, Struct, Trait,
35-
TypeAlias, Union,
34+
ImplBlock, Trait,
3635
};
3736

3837
impl Ty {
@@ -693,42 +692,6 @@ fn type_for_type_alias(db: &impl HirDatabase, t: TypeAliasId) -> Ty {
693692
inner.subst(&substs)
694693
}
695694

696-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
697-
pub enum TypableDef {
698-
Function(Function),
699-
Adt(Adt),
700-
EnumVariant(EnumVariant),
701-
TypeAlias(TypeAlias),
702-
Const(Const),
703-
Static(Static),
704-
BuiltinType(BuiltinType),
705-
}
706-
impl_froms!(
707-
TypableDef: Function,
708-
Adt(Struct, Enum, Union),
709-
EnumVariant,
710-
TypeAlias,
711-
Const,
712-
Static,
713-
BuiltinType
714-
);
715-
716-
impl From<ModuleDef> for Option<TypableDef> {
717-
fn from(def: ModuleDef) -> Option<TypableDef> {
718-
let res = match def {
719-
ModuleDef::Function(f) => f.into(),
720-
ModuleDef::Adt(adt) => adt.into(),
721-
ModuleDef::EnumVariant(v) => v.into(),
722-
ModuleDef::TypeAlias(t) => t.into(),
723-
ModuleDef::Const(v) => v.into(),
724-
ModuleDef::Static(v) => v.into(),
725-
ModuleDef::BuiltinType(t) => t.into(),
726-
ModuleDef::Module(_) | ModuleDef::Trait(_) => return None,
727-
};
728-
Some(res)
729-
}
730-
}
731-
732695
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
733696
pub enum CallableDef {
734697
FunctionId(FunctionId),

crates/ra_hir/src/ty/op.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
use hir_def::expr::{BinaryOp, CmpOp};
33

44
use super::{InferTy, Ty, TypeCtor};
5-
use crate::{
6-
ty::ApplicationTy,
7-
};
5+
use crate::ty::ApplicationTy;
86

97
pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty {
108
match op {

0 commit comments

Comments
 (0)