diff options
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/infer.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 19 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lower.rs | 13 |
3 files changed, 9 insertions, 30 deletions
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 5c56c2eb0..2ce4f65cc 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs | |||
@@ -18,8 +18,6 @@ use std::mem; | |||
18 | use std::ops::Index; | 18 | use std::ops::Index; |
19 | use std::sync::Arc; | 19 | use std::sync::Arc; |
20 | 20 | ||
21 | use rustc_hash::FxHashMap; | ||
22 | |||
23 | use hir_def::{ | 21 | use hir_def::{ |
24 | body::Body, | 22 | body::Body, |
25 | data::{ConstData, FunctionData, StaticData}, | 23 | data::{ConstData, FunctionData, StaticData}, |
@@ -35,6 +33,8 @@ use hir_expand::{diagnostics::DiagnosticSink, name::name}; | |||
35 | use ra_arena::map::ArenaMap; | 33 | use ra_arena::map::ArenaMap; |
36 | use ra_prof::profile; | 34 | use ra_prof::profile; |
37 | use ra_syntax::SmolStr; | 35 | use ra_syntax::SmolStr; |
36 | use rustc_hash::FxHashMap; | ||
37 | use stdx::impl_from; | ||
38 | 38 | ||
39 | use super::{ | 39 | use super::{ |
40 | primitive::{FloatTy, IntTy}, | 40 | primitive::{FloatTy, IntTy}, |
@@ -84,8 +84,7 @@ enum ExprOrPatId { | |||
84 | ExprId(ExprId), | 84 | ExprId(ExprId), |
85 | PatId(PatId), | 85 | PatId(PatId), |
86 | } | 86 | } |
87 | 87 | impl_from!(ExprId, PatId for ExprOrPatId); | |
88 | impl_froms!(ExprOrPatId: ExprId, PatId); | ||
89 | 88 | ||
90 | /// Binding modes inferred for patterns. | 89 | /// Binding modes inferred for patterns. |
91 | /// https://doc.rust-lang.org/reference/patterns.html#binding-modes | 90 | /// https://doc.rust-lang.org/reference/patterns.html#binding-modes |
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 34f0bd4ce..2652d200f 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -6,25 +6,6 @@ macro_rules! eprintln { | |||
6 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; | 6 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; |
7 | } | 7 | } |
8 | 8 | ||
9 | macro_rules! impl_froms { | ||
10 | ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { | ||
11 | $( | ||
12 | impl From<$v> for $e { | ||
13 | fn from(it: $v) -> $e { | ||
14 | $e::$v(it) | ||
15 | } | ||
16 | } | ||
17 | $($( | ||
18 | impl From<$sv> for $e { | ||
19 | fn from(it: $sv) -> $e { | ||
20 | $e::$v($v::$sv(it)) | ||
21 | } | ||
22 | } | ||
23 | )*)? | ||
24 | )* | ||
25 | } | ||
26 | } | ||
27 | |||
28 | mod autoderef; | 9 | mod autoderef; |
29 | pub mod primitive; | 10 | pub mod primitive; |
30 | pub mod traits; | 11 | pub mod traits; |
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 3af8d55a1..101b8aebe 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs | |||
@@ -5,10 +5,7 @@ | |||
5 | //! - Building the type for an item: This happens through the `type_for_def` query. | 5 | //! - Building the type for an item: This happens through the `type_for_def` query. |
6 | //! | 6 | //! |
7 | //! This usually involves resolving names, collecting generic arguments etc. | 7 | //! This usually involves resolving names, collecting generic arguments etc. |
8 | use std::iter; | 8 | use std::{iter, sync::Arc}; |
9 | use std::sync::Arc; | ||
10 | |||
11 | use smallvec::SmallVec; | ||
12 | 9 | ||
13 | use hir_def::{ | 10 | use hir_def::{ |
14 | adt::StructKind, | 11 | adt::StructKind, |
@@ -24,6 +21,8 @@ use hir_def::{ | |||
24 | use hir_expand::name::Name; | 21 | use hir_expand::name::Name; |
25 | use ra_arena::map::ArenaMap; | 22 | use ra_arena::map::ArenaMap; |
26 | use ra_db::CrateId; | 23 | use ra_db::CrateId; |
24 | use smallvec::SmallVec; | ||
25 | use stdx::impl_from; | ||
27 | use test_utils::mark; | 26 | use test_utils::mark; |
28 | 27 | ||
29 | use crate::{ | 28 | use crate::{ |
@@ -1110,7 +1109,7 @@ pub enum CallableDef { | |||
1110 | StructId(StructId), | 1109 | StructId(StructId), |
1111 | EnumVariantId(EnumVariantId), | 1110 | EnumVariantId(EnumVariantId), |
1112 | } | 1111 | } |
1113 | impl_froms!(CallableDef: FunctionId, StructId, EnumVariantId); | 1112 | impl_from!(FunctionId, StructId, EnumVariantId for CallableDef); |
1114 | 1113 | ||
1115 | impl CallableDef { | 1114 | impl CallableDef { |
1116 | pub fn krate(self, db: &dyn HirDatabase) -> CrateId { | 1115 | pub fn krate(self, db: &dyn HirDatabase) -> CrateId { |
@@ -1140,7 +1139,7 @@ pub enum TyDefId { | |||
1140 | AdtId(AdtId), | 1139 | AdtId(AdtId), |
1141 | TypeAliasId(TypeAliasId), | 1140 | TypeAliasId(TypeAliasId), |
1142 | } | 1141 | } |
1143 | impl_froms!(TyDefId: BuiltinType, AdtId(StructId, EnumId, UnionId), TypeAliasId); | 1142 | impl_from!(BuiltinType, AdtId(StructId, EnumId, UnionId), TypeAliasId for TyDefId); |
1144 | 1143 | ||
1145 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 1144 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
1146 | pub enum ValueTyDefId { | 1145 | pub enum ValueTyDefId { |
@@ -1150,7 +1149,7 @@ pub enum ValueTyDefId { | |||
1150 | ConstId(ConstId), | 1149 | ConstId(ConstId), |
1151 | StaticId(StaticId), | 1150 | StaticId(StaticId), |
1152 | } | 1151 | } |
1153 | impl_froms!(ValueTyDefId: FunctionId, StructId, EnumVariantId, ConstId, StaticId); | 1152 | impl_from!(FunctionId, StructId, EnumVariantId, ConstId, StaticId for ValueTyDefId); |
1154 | 1153 | ||
1155 | /// Build the declared type of an item. This depends on the namespace; e.g. for | 1154 | /// Build the declared type of an item. This depends on the namespace; e.g. for |
1156 | /// `struct Foo(usize)`, we have two types: The type of the struct itself, and | 1155 | /// `struct Foo(usize)`, we have two types: The type of the struct itself, and |