diff options
author | Josh Mcguigan <[email protected]> | 2020-03-01 15:08:05 +0000 |
---|---|---|
committer | Josh Mcguigan <[email protected]> | 2020-03-01 15:35:15 +0000 |
commit | d0e282f6b1a8c698212f7f76de2ff122e36e17a2 (patch) | |
tree | 8e7fc59e226b87b9fdec11a57f82f98992c9d396 /crates/ra_hir_ty/src/infer/pat.rs | |
parent | f353625705854877a8347c3a46f15e294a9338e4 (diff) |
handle arbitrary length slices
Diffstat (limited to 'crates/ra_hir_ty/src/infer/pat.rs')
-rw-r--r-- | crates/ra_hir_ty/src/infer/pat.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index b991720ff..3fe1a4abb 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs | |||
@@ -188,10 +188,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
188 | Pat::Slice { prefix, slice, suffix } => { | 188 | Pat::Slice { prefix, slice, suffix } => { |
189 | if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected { | 189 | if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected { |
190 | match (prefix.as_slice(), slice, suffix.as_slice()) { | 190 | match (prefix.as_slice(), slice, suffix.as_slice()) { |
191 | ([prefix_pat_id], None, []) => { | 191 | (prefix_pat_ids, None, []) => { |
192 | let ty = self.infer_pat(*prefix_pat_id, ¶meters.0[0], default_bm); | 192 | for pat_id in prefix_pat_ids { |
193 | self.infer_pat(*pat_id, parameters.as_single(), default_bm); | ||
194 | } | ||
193 | 195 | ||
194 | Ty::apply_one(TypeCtor::Slice, ty) | 196 | Ty::apply_one(TypeCtor::Slice, parameters.as_single().clone()) |
195 | }, | 197 | }, |
196 | _ => Ty::Unknown, | 198 | _ => Ty::Unknown, |
197 | } | 199 | } |