aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer/pat.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/infer/pat.rs')
-rw-r--r--crates/ra_hir_ty/src/infer/pat.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs
index bf8ea192b..7a84e47f8 100644
--- a/crates/ra_hir_ty/src/infer/pat.rs
+++ b/crates/ra_hir_ty/src/infer/pat.rs
@@ -185,6 +185,19 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
185 self.write_pat_ty(pat, bound_ty); 185 self.write_pat_ty(pat, bound_ty);
186 return inner_ty; 186 return inner_ty;
187 } 187 }
188 Pat::Slice { prefix, slice: _slice, suffix } => {
189 let (container_ty, elem_ty) = match &expected {
190 ty_app!(TypeCtor::Array, st) => (TypeCtor::Array, st.as_single().clone()),
191 ty_app!(TypeCtor::Slice, st) => (TypeCtor::Slice, st.as_single().clone()),
192 _ => (TypeCtor::Slice, Ty::Unknown),
193 };
194
195 for pat_id in prefix.iter().chain(suffix) {
196 self.infer_pat(*pat_id, &elem_ty, default_bm);
197 }
198
199 Ty::apply_one(container_ty, elem_ty)
200 }
188 _ => Ty::Unknown, 201 _ => Ty::Unknown,
189 }; 202 };
190 // use a new type variable if we got Ty::Unknown here 203 // use a new type variable if we got Ty::Unknown here