From b9ef7a6b987eea4b0b14298fbbe44d912806f50f Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Sun, 1 Mar 2020 12:13:05 -0800 Subject: remove match statement, handle suffix --- crates/ra_hir_ty/src/infer/pat.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'crates/ra_hir_ty/src/infer') diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index 3fe1a4abb..06b09af82 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs @@ -185,21 +185,18 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { self.write_pat_ty(pat, bound_ty); return inner_ty; } - Pat::Slice { prefix, slice, suffix } => { - if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected { - match (prefix.as_slice(), slice, suffix.as_slice()) { - (prefix_pat_ids, None, []) => { - for pat_id in prefix_pat_ids { - self.infer_pat(*pat_id, parameters.as_single(), default_bm); - } - - Ty::apply_one(TypeCtor::Slice, parameters.as_single().clone()) - }, - _ => Ty::Unknown, + Pat::Slice { prefix, slice: _slice, suffix } => { + let ty = if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected { + for pat_id in prefix.iter().chain(suffix) { + self.infer_pat(*pat_id, parameters.as_single(), default_bm); } + + parameters.as_single().clone() } else { Ty::Unknown - } + }; + + Ty::apply_one(TypeCtor::Slice, ty) } _ => Ty::Unknown, }; -- cgit v1.2.3