diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer/unify.rs | 4 |
2 files changed, 8 insertions, 10 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index a2dc92370..9228dd314 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -116,16 +116,16 @@ pub struct InferenceResult { | |||
116 | 116 | ||
117 | impl InferenceResult { | 117 | impl InferenceResult { |
118 | pub fn method_resolution(&self, expr: ExprId) -> Option<Function> { | 118 | pub fn method_resolution(&self, expr: ExprId) -> Option<Function> { |
119 | self.method_resolutions.get(&expr).map(|it| *it) | 119 | self.method_resolutions.get(&expr).copied() |
120 | } | 120 | } |
121 | pub fn field_resolution(&self, expr: ExprId) -> Option<StructField> { | 121 | pub fn field_resolution(&self, expr: ExprId) -> Option<StructField> { |
122 | self.field_resolutions.get(&expr).map(|it| *it) | 122 | self.field_resolutions.get(&expr).copied() |
123 | } | 123 | } |
124 | pub fn assoc_resolutions_for_expr(&self, id: ExprId) -> Option<ImplItem> { | 124 | pub fn assoc_resolutions_for_expr(&self, id: ExprId) -> Option<ImplItem> { |
125 | self.assoc_resolutions.get(&id.into()).map(|it| *it) | 125 | self.assoc_resolutions.get(&id.into()).copied() |
126 | } | 126 | } |
127 | pub fn assoc_resolutions_for_pat(&self, id: PatId) -> Option<ImplItem> { | 127 | pub fn assoc_resolutions_for_pat(&self, id: PatId) -> Option<ImplItem> { |
128 | self.assoc_resolutions.get(&id.into()).map(|it| *it) | 128 | self.assoc_resolutions.get(&id.into()).copied() |
129 | } | 129 | } |
130 | pub(crate) fn add_diagnostics( | 130 | pub(crate) fn add_diagnostics( |
131 | &self, | 131 | &self, |
@@ -239,8 +239,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
239 | &self.resolver, | 239 | &self.resolver, |
240 | type_ref, | 240 | type_ref, |
241 | ); | 241 | ); |
242 | let ty = self.insert_type_vars(ty); | 242 | self.insert_type_vars(ty) |
243 | ty | ||
244 | } | 243 | } |
245 | 244 | ||
246 | fn unify_substs(&mut self, substs1: &Substs, substs2: &Substs, depth: usize) -> bool { | 245 | fn unify_substs(&mut self, substs1: &Substs, substs2: &Substs, depth: usize) -> bool { |
@@ -973,8 +972,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
973 | 972 | ||
974 | for (arg_pat, arg_type) in args.iter().zip(arg_types.iter()) { | 973 | for (arg_pat, arg_type) in args.iter().zip(arg_types.iter()) { |
975 | let expected = if let Some(type_ref) = arg_type { | 974 | let expected = if let Some(type_ref) = arg_type { |
976 | let ty = self.make_ty(type_ref); | 975 | self.make_ty(type_ref) |
977 | ty | ||
978 | } else { | 976 | } else { |
979 | Ty::Unknown | 977 | Ty::Unknown |
980 | }; | 978 | }; |
diff --git a/crates/ra_hir/src/ty/infer/unify.rs b/crates/ra_hir/src/ty/infer/unify.rs index 04633bdb2..49bf5b946 100644 --- a/crates/ra_hir/src/ty/infer/unify.rs +++ b/crates/ra_hir/src/ty/infer/unify.rs | |||
@@ -102,7 +102,7 @@ impl<T> Canonicalized<T> { | |||
102 | ty.fold(&mut |ty| match ty { | 102 | ty.fold(&mut |ty| match ty { |
103 | Ty::Bound(idx) => { | 103 | Ty::Bound(idx) => { |
104 | if (idx as usize) < self.free_vars.len() { | 104 | if (idx as usize) < self.free_vars.len() { |
105 | Ty::Infer(self.free_vars[idx as usize].clone()) | 105 | Ty::Infer(self.free_vars[idx as usize]) |
106 | } else { | 106 | } else { |
107 | Ty::Bound(idx) | 107 | Ty::Bound(idx) |
108 | } | 108 | } |
@@ -120,7 +120,7 @@ impl<T> Canonicalized<T> { | |||
120 | let new_vars = | 120 | let new_vars = |
121 | (0..solution.num_vars).map(|_| ctx.new_type_var()).collect::<Vec<_>>().into(); | 121 | (0..solution.num_vars).map(|_| ctx.new_type_var()).collect::<Vec<_>>().into(); |
122 | for (i, ty) in solution.value.into_iter().enumerate() { | 122 | for (i, ty) in solution.value.into_iter().enumerate() { |
123 | let var = self.free_vars[i].clone(); | 123 | let var = self.free_vars[i]; |
124 | ctx.unify(&Ty::Infer(var), &ty.subst_bound_vars(&new_vars)); | 124 | ctx.unify(&Ty::Infer(var), &ty.subst_bound_vars(&new_vars)); |
125 | } | 125 | } |
126 | } | 126 | } |