diff options
Diffstat (limited to 'crates/ra_hir_ty/src/infer')
-rw-r--r-- | crates/ra_hir_ty/src/infer/pat.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index 06b09af82..623e52599 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs | |||
@@ -12,7 +12,7 @@ use hir_expand::name::Name; | |||
12 | use test_utils::tested_by; | 12 | use test_utils::tested_by; |
13 | 13 | ||
14 | use super::{BindingMode, InferenceContext}; | 14 | use super::{BindingMode, InferenceContext}; |
15 | use crate::{db::HirDatabase, utils::variant_data, Substs, Ty, TypeCtor, ApplicationTy}; | 15 | use crate::{db::HirDatabase, utils::variant_data, Substs, Ty, TypeCtor}; |
16 | 16 | ||
17 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { | 17 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { |
18 | fn infer_tuple_struct_pat( | 18 | fn infer_tuple_struct_pat( |
@@ -186,17 +186,21 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
186 | return inner_ty; | 186 | return inner_ty; |
187 | } | 187 | } |
188 | Pat::Slice { prefix, slice: _slice, suffix } => { | 188 | Pat::Slice { prefix, slice: _slice, suffix } => { |
189 | let ty = if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected { | 189 | let (container_ty, elem_ty) = match &expected { |
190 | for pat_id in prefix.iter().chain(suffix) { | 190 | ty_app!(TypeCtor::Array, st) => { |
191 | self.infer_pat(*pat_id, parameters.as_single(), default_bm); | 191 | (TypeCtor::Array, st.as_single().clone()) |
192 | } | 192 | }, |
193 | 193 | ty_app!(TypeCtor::Slice, st) => { | |
194 | parameters.as_single().clone() | 194 | (TypeCtor::Slice, st.as_single().clone()) |
195 | } else { | 195 | }, |
196 | Ty::Unknown | 196 | _ => (TypeCtor::Slice, Ty::Unknown), |
197 | }; | 197 | }; |
198 | 198 | ||
199 | Ty::apply_one(TypeCtor::Slice, ty) | 199 | for pat_id in prefix.iter().chain(suffix) { |
200 | self.infer_pat(*pat_id, &elem_ty, default_bm); | ||
201 | } | ||
202 | |||
203 | Ty::apply_one(container_ty, elem_ty) | ||
200 | } | 204 | } |
201 | _ => Ty::Unknown, | 205 | _ => Ty::Unknown, |
202 | }; | 206 | }; |