diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/from_id.rs | 60 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 39 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/op.rs | 4 |
4 files changed, 7 insertions, 98 deletions
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs index 38daa5e59..e96a18d12 100644 --- a/crates/ra_hir/src/from_id.rs +++ b/crates/ra_hir/src/from_id.rs | |||
@@ -4,13 +4,13 @@ | |||
4 | //! are splitting the hir. | 4 | //! are splitting the hir. |
5 | 5 | ||
6 | use hir_def::{ | 6 | use hir_def::{ |
7 | AdtId, AssocItemId, AttrDefId, ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, | 7 | AdtId, AssocItemId, AttrDefId, DefWithBodyId, EnumVariantId, GenericDefId, ModuleDefId, |
8 | GenericDefId, ModuleDefId, StaticId, StructFieldId, StructId, TypeAliasId, UnionId, VariantId, | 8 | StructFieldId, VariantId, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | ty::TypableDef, Adt, AssocItem, AttrDef, Const, Crate, DefWithBody, EnumVariant, Function, | 12 | Adt, AssocItem, AttrDef, Crate, DefWithBody, EnumVariant, GenericDef, ModuleDef, StructField, |
13 | GenericDef, ModuleDef, Static, StructField, TypeAlias, VariantDef, | 13 | VariantDef, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | impl From<ra_db::CrateId> for Crate { | 16 | impl From<ra_db::CrateId> for Crate { |
@@ -137,58 +137,6 @@ impl From<GenericDef> for GenericDefId { | |||
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
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 | |||
192 | impl From<Adt> for GenericDefId { | 140 | impl From<Adt> for GenericDefId { |
193 | fn from(id: Adt) -> Self { | 141 | fn from(id: Adt) -> Self { |
194 | match id { | 142 | match id { |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index a26776b26..e4ba8afa6 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -38,7 +38,7 @@ pub use lower::CallableDef; | |||
38 | pub(crate) use lower::{ | 38 | pub(crate) use lower::{ |
39 | callable_item_sig, field_types_query, generic_defaults_query, | 39 | callable_item_sig, field_types_query, generic_defaults_query, |
40 | generic_predicates_for_param_query, generic_predicates_query, ty_query, value_ty_query, | 40 | generic_predicates_for_param_query, generic_predicates_query, ty_query, value_ty_query, |
41 | TyDefId, TypableDef, ValueTyDefId, | 41 | TyDefId, ValueTyDefId, |
42 | }; | 42 | }; |
43 | pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; | 43 | pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; |
44 | 44 | ||
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index d776b6cd0..5dce2f342 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -31,8 +31,7 @@ use crate::{ | |||
31 | utils::{all_super_traits, associated_type_by_name_including_super_traits, variant_data}, | 31 | utils::{all_super_traits, associated_type_by_name_including_super_traits, variant_data}, |
32 | }, | 32 | }, |
33 | util::make_mut_slice, | 33 | util::make_mut_slice, |
34 | Adt, Const, Enum, EnumVariant, Function, ImplBlock, ModuleDef, Static, Struct, Trait, | 34 | ImplBlock, Trait, |
35 | TypeAlias, Union, | ||
36 | }; | 35 | }; |
37 | 36 | ||
38 | impl Ty { | 37 | impl Ty { |
@@ -694,42 +693,6 @@ fn type_for_type_alias(db: &impl HirDatabase, t: TypeAliasId) -> Ty { | |||
694 | } | 693 | } |
695 | 694 | ||
696 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 695 | #[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 | |||
732 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | ||
733 | pub enum CallableDef { | 696 | pub enum CallableDef { |
734 | FunctionId(FunctionId), | 697 | FunctionId(FunctionId), |
735 | StructId(StructId), | 698 | StructId(StructId), |
diff --git a/crates/ra_hir/src/ty/op.rs b/crates/ra_hir/src/ty/op.rs index 80d4111a0..cc6e244f4 100644 --- a/crates/ra_hir/src/ty/op.rs +++ b/crates/ra_hir/src/ty/op.rs | |||
@@ -2,9 +2,7 @@ | |||
2 | use hir_def::expr::{BinaryOp, CmpOp}; | 2 | use hir_def::expr::{BinaryOp, CmpOp}; |
3 | 3 | ||
4 | use super::{InferTy, Ty, TypeCtor}; | 4 | use super::{InferTy, Ty, TypeCtor}; |
5 | use crate::{ | 5 | use crate::ty::ApplicationTy; |
6 | ty::ApplicationTy, | ||
7 | }; | ||
8 | 6 | ||
9 | pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { | 7 | pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { |
10 | match op { | 8 | match op { |