mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Remove TypableDef
This commit is contained in:
parent
d6e8f27488
commit
12501fcdd0
4 changed files with 7 additions and 98 deletions
|
@ -4,13 +4,13 @@
|
|||
//! are splitting the hir.
|
||||
|
||||
use hir_def::{
|
||||
AdtId, AssocItemId, AttrDefId, ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId,
|
||||
GenericDefId, ModuleDefId, StaticId, StructFieldId, StructId, TypeAliasId, UnionId, VariantId,
|
||||
AdtId, AssocItemId, AttrDefId, DefWithBodyId, EnumVariantId, GenericDefId, ModuleDefId,
|
||||
StructFieldId, VariantId,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
ty::TypableDef, Adt, AssocItem, AttrDef, Const, Crate, DefWithBody, EnumVariant, Function,
|
||||
GenericDef, ModuleDef, Static, StructField, TypeAlias, VariantDef,
|
||||
Adt, AssocItem, AttrDef, Crate, DefWithBody, EnumVariant, GenericDef, ModuleDef, StructField,
|
||||
VariantDef,
|
||||
};
|
||||
|
||||
impl From<ra_db::CrateId> for Crate {
|
||||
|
@ -137,58 +137,6 @@ impl From<GenericDef> for GenericDefId {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<AdtId> for TypableDef {
|
||||
fn from(id: AdtId) -> Self {
|
||||
Adt::from(id).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StructId> for TypableDef {
|
||||
fn from(id: StructId) -> Self {
|
||||
AdtId::StructId(id).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<UnionId> for TypableDef {
|
||||
fn from(id: UnionId) -> Self {
|
||||
AdtId::UnionId(id).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EnumId> for TypableDef {
|
||||
fn from(id: EnumId) -> Self {
|
||||
AdtId::EnumId(id).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EnumVariantId> for TypableDef {
|
||||
fn from(id: EnumVariantId) -> Self {
|
||||
EnumVariant::from(id).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TypeAliasId> for TypableDef {
|
||||
fn from(id: TypeAliasId) -> Self {
|
||||
TypeAlias::from(id).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FunctionId> for TypableDef {
|
||||
fn from(id: FunctionId) -> Self {
|
||||
Function::from(id).into()
|
||||
}
|
||||
}
|
||||
impl From<ConstId> for TypableDef {
|
||||
fn from(id: ConstId) -> Self {
|
||||
Const::from(id).into()
|
||||
}
|
||||
}
|
||||
impl From<StaticId> for TypableDef {
|
||||
fn from(id: StaticId) -> Self {
|
||||
Static::from(id).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Adt> for GenericDefId {
|
||||
fn from(id: Adt) -> Self {
|
||||
match id {
|
||||
|
|
|
@ -38,7 +38,7 @@ pub use lower::CallableDef;
|
|||
pub(crate) use lower::{
|
||||
callable_item_sig, field_types_query, generic_defaults_query,
|
||||
generic_predicates_for_param_query, generic_predicates_query, ty_query, value_ty_query,
|
||||
TyDefId, TypableDef, ValueTyDefId,
|
||||
TyDefId, ValueTyDefId,
|
||||
};
|
||||
pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ use crate::{
|
|||
utils::{all_super_traits, associated_type_by_name_including_super_traits, variant_data},
|
||||
},
|
||||
util::make_mut_slice,
|
||||
Adt, Const, Enum, EnumVariant, Function, ImplBlock, ModuleDef, Static, Struct, Trait,
|
||||
TypeAlias, Union,
|
||||
ImplBlock, Trait,
|
||||
};
|
||||
|
||||
impl Ty {
|
||||
|
@ -693,42 +692,6 @@ fn type_for_type_alias(db: &impl HirDatabase, t: TypeAliasId) -> Ty {
|
|||
inner.subst(&substs)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum TypableDef {
|
||||
Function(Function),
|
||||
Adt(Adt),
|
||||
EnumVariant(EnumVariant),
|
||||
TypeAlias(TypeAlias),
|
||||
Const(Const),
|
||||
Static(Static),
|
||||
BuiltinType(BuiltinType),
|
||||
}
|
||||
impl_froms!(
|
||||
TypableDef: Function,
|
||||
Adt(Struct, Enum, Union),
|
||||
EnumVariant,
|
||||
TypeAlias,
|
||||
Const,
|
||||
Static,
|
||||
BuiltinType
|
||||
);
|
||||
|
||||
impl From<ModuleDef> for Option<TypableDef> {
|
||||
fn from(def: ModuleDef) -> Option<TypableDef> {
|
||||
let res = match def {
|
||||
ModuleDef::Function(f) => f.into(),
|
||||
ModuleDef::Adt(adt) => adt.into(),
|
||||
ModuleDef::EnumVariant(v) => v.into(),
|
||||
ModuleDef::TypeAlias(t) => t.into(),
|
||||
ModuleDef::Const(v) => v.into(),
|
||||
ModuleDef::Static(v) => v.into(),
|
||||
ModuleDef::BuiltinType(t) => t.into(),
|
||||
ModuleDef::Module(_) | ModuleDef::Trait(_) => return None,
|
||||
};
|
||||
Some(res)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum CallableDef {
|
||||
FunctionId(FunctionId),
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
use hir_def::expr::{BinaryOp, CmpOp};
|
||||
|
||||
use super::{InferTy, Ty, TypeCtor};
|
||||
use crate::{
|
||||
ty::ApplicationTy,
|
||||
};
|
||||
use crate::ty::ApplicationTy;
|
||||
|
||||
pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty {
|
||||
match op {
|
||||
|
|
Loading…
Reference in a new issue