diff options
author | Lukas Wirth <[email protected]> | 2021-04-06 10:45:41 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-04-06 10:45:41 +0100 |
commit | 9fbba7bc45ec6bea9468931d9d9fdd0141826f0a (patch) | |
tree | 266da1eafcd60457fa99cc422a415e27992c08d7 /crates/hir_ty/src/infer/pat.rs | |
parent | 047b5313013383fc4fafaef6d6d8d6a64549e3cb (diff) |
Add chalk_ir::Const to TyKind::Array
Diffstat (limited to 'crates/hir_ty/src/infer/pat.rs')
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 2848a393c..c1d7a6b76 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -214,17 +214,20 @@ impl<'a> InferenceContext<'a> { | |||
214 | return inner_ty; | 214 | return inner_ty; |
215 | } | 215 | } |
216 | Pat::Slice { prefix, slice, suffix } => { | 216 | Pat::Slice { prefix, slice, suffix } => { |
217 | let (container_ty, elem_ty): (fn(_) -> _, _) = match expected.kind(&Interner) { | 217 | let elem_ty = match expected.kind(&Interner) { |
218 | TyKind::Array(st) => (TyKind::Array, st.clone()), | 218 | TyKind::Array(st, _) | TyKind::Slice(st) => st.clone(), |
219 | TyKind::Slice(st) => (TyKind::Slice, st.clone()), | 219 | _ => self.err_ty(), |
220 | _ => (TyKind::Slice, self.err_ty()), | ||
221 | }; | 220 | }; |
222 | 221 | ||
223 | for pat_id in prefix.iter().chain(suffix) { | 222 | for pat_id in prefix.iter().chain(suffix) { |
224 | self.infer_pat(*pat_id, &elem_ty, default_bm); | 223 | self.infer_pat(*pat_id, &elem_ty, default_bm); |
225 | } | 224 | } |
226 | 225 | ||
227 | let pat_ty = container_ty(elem_ty).intern(&Interner); | 226 | let pat_ty = match expected.kind(&Interner) { |
227 | TyKind::Array(_, const_) => TyKind::Array(elem_ty, const_.clone()), | ||
228 | _ => TyKind::Slice(elem_ty), | ||
229 | } | ||
230 | .intern(&Interner); | ||
228 | if let Some(slice_pat_id) = slice { | 231 | if let Some(slice_pat_id) = slice { |
229 | self.infer_pat(*slice_pat_id, &pat_ty, default_bm); | 232 | self.infer_pat(*slice_pat_id, &pat_ty, default_bm); |
230 | } | 233 | } |