diff options
author | Josh Mcguigan <[email protected]> | 2020-03-01 14:25:38 +0000 |
---|---|---|
committer | Josh Mcguigan <[email protected]> | 2020-03-01 14:25:38 +0000 |
commit | f353625705854877a8347c3a46f15e294a9338e4 (patch) | |
tree | 5a595ce0b149a0565ab562165dcd44a1642c0319 /crates/ra_hir_ty/src/infer | |
parent | 6db2da4993d3956fc7c8ebf152963a132611426a (diff) |
match single prefix slice
Diffstat (limited to 'crates/ra_hir_ty/src/infer')
-rw-r--r-- | crates/ra_hir_ty/src/infer/pat.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index bf8ea192b..b991720ff 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}; | 15 | use crate::{db::HirDatabase, utils::variant_data, Substs, Ty, TypeCtor, ApplicationTy}; |
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( |
@@ -185,6 +185,20 @@ 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, suffix } => { | ||
189 | if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected { | ||
190 | match (prefix.as_slice(), slice, suffix.as_slice()) { | ||
191 | ([prefix_pat_id], None, []) => { | ||
192 | let ty = self.infer_pat(*prefix_pat_id, ¶meters.0[0], default_bm); | ||
193 | |||
194 | Ty::apply_one(TypeCtor::Slice, ty) | ||
195 | }, | ||
196 | _ => Ty::Unknown, | ||
197 | } | ||
198 | } else { | ||
199 | Ty::Unknown | ||
200 | } | ||
201 | } | ||
188 | _ => Ty::Unknown, | 202 | _ => Ty::Unknown, |
189 | }; | 203 | }; |
190 | // use a new type variable if we got Ty::Unknown here | 204 | // use a new type variable if we got Ty::Unknown here |