aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer/pat.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer/pat.rs')
-rw-r--r--crates/hir_ty/src/infer/pat.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs
index a16755cda..9e8ca18ef 100644
--- a/crates/hir_ty/src/infer/pat.rs
+++ b/crates/hir_ty/src/infer/pat.rs
@@ -158,12 +158,12 @@ impl<'a> InferenceContext<'a> {
158 if mutability != exp_mut { 158 if mutability != exp_mut {
159 // FIXME: emit type error? 159 // FIXME: emit type error?
160 } 160 }
161 inner_ty 161 inner_ty.clone()
162 } 162 }
163 _ => &Ty(TyKind::Unknown), 163 _ => self.result.standard_types.unknown.clone(),
164 }; 164 };
165 let subty = self.infer_pat(*pat, expectation, default_bm); 165 let subty = self.infer_pat(*pat, &expectation, default_bm);
166 TyKind::Ref(mutability, Substs::single(subty)).intern(&Interner) 166 TyKind::Ref(mutability, subty).intern(&Interner)
167 } 167 }
168 Pat::TupleStruct { path: p, args: subpats, ellipsis } => self.infer_tuple_struct_pat( 168 Pat::TupleStruct { path: p, args: subpats, ellipsis } => self.infer_tuple_struct_pat(
169 p.as_ref(), 169 p.as_ref(),
@@ -196,7 +196,7 @@ impl<'a> InferenceContext<'a> {
196 196
197 let bound_ty = match mode { 197 let bound_ty = match mode {
198 BindingMode::Ref(mutability) => { 198 BindingMode::Ref(mutability) => {
199 TyKind::Ref(mutability, Substs::single(inner_ty.clone())).intern(&Interner) 199 TyKind::Ref(mutability, inner_ty.clone()).intern(&Interner)
200 } 200 }
201 BindingMode::Move => inner_ty.clone(), 201 BindingMode::Move => inner_ty.clone(),
202 }; 202 };
@@ -206,8 +206,8 @@ impl<'a> InferenceContext<'a> {
206 } 206 }
207 Pat::Slice { prefix, slice, suffix } => { 207 Pat::Slice { prefix, slice, suffix } => {
208 let (container_ty, elem_ty): (fn(_) -> _, _) = match expected.interned(&Interner) { 208 let (container_ty, elem_ty): (fn(_) -> _, _) = match expected.interned(&Interner) {
209 TyKind::Array(st) => (TyKind::Array, st.as_single().clone()), 209 TyKind::Array(st) => (TyKind::Array, st.clone()),
210 TyKind::Slice(st) => (TyKind::Slice, st.as_single().clone()), 210 TyKind::Slice(st) => (TyKind::Slice, st.clone()),
211 _ => (TyKind::Slice, self.err_ty()), 211 _ => (TyKind::Slice, self.err_ty()),
212 }; 212 };
213 213
@@ -215,7 +215,7 @@ impl<'a> InferenceContext<'a> {
215 self.infer_pat(*pat_id, &elem_ty, default_bm); 215 self.infer_pat(*pat_id, &elem_ty, default_bm);
216 } 216 }
217 217
218 let pat_ty = container_ty(Substs::single(elem_ty)).intern(&Interner); 218 let pat_ty = container_ty(elem_ty).intern(&Interner);
219 if let Some(slice_pat_id) = slice { 219 if let Some(slice_pat_id) = slice {
220 self.infer_pat(*slice_pat_id, &pat_ty, default_bm); 220 self.infer_pat(*slice_pat_id, &pat_ty, default_bm);
221 } 221 }
@@ -232,11 +232,11 @@ impl<'a> InferenceContext<'a> {
232 Pat::Box { inner } => match self.resolve_boxed_box() { 232 Pat::Box { inner } => match self.resolve_boxed_box() {
233 Some(box_adt) => { 233 Some(box_adt) => {
234 let inner_expected = match expected.as_adt() { 234 let inner_expected = match expected.as_adt() {
235 Some((adt, substs)) if adt == box_adt => substs.as_single(), 235 Some((adt, substs)) if adt == box_adt => substs.as_single().clone(),
236 _ => &Ty(TyKind::Unknown), 236 _ => self.result.standard_types.unknown.clone(),
237 }; 237 };
238 238
239 let inner_ty = self.infer_pat(*inner, inner_expected, default_bm); 239 let inner_ty = self.infer_pat(*inner, &inner_expected, default_bm);
240 Ty::adt_ty(box_adt, Substs::single(inner_ty)) 240 Ty::adt_ty(box_adt, Substs::single(inner_ty))
241 } 241 }
242 None => self.err_ty(), 242 None => self.err_ty(),