diff options
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r-- | crates/ra_hir_ty/src/infer/pat.rs | 21 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/patterns.rs | 4 |
2 files changed, 11 insertions, 14 deletions
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> { | |||
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 } => { | 188 | Pat::Slice { prefix, slice: _slice, suffix } => { |
189 | if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected { | 189 | let ty = if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected { |
190 | match (prefix.as_slice(), slice, suffix.as_slice()) { | 190 | for pat_id in prefix.iter().chain(suffix) { |
191 | (prefix_pat_ids, None, []) => { | 191 | self.infer_pat(*pat_id, parameters.as_single(), default_bm); |
192 | for pat_id in prefix_pat_ids { | ||
193 | self.infer_pat(*pat_id, parameters.as_single(), default_bm); | ||
194 | } | ||
195 | |||
196 | Ty::apply_one(TypeCtor::Slice, parameters.as_single().clone()) | ||
197 | }, | ||
198 | _ => Ty::Unknown, | ||
199 | } | 192 | } |
193 | |||
194 | parameters.as_single().clone() | ||
200 | } else { | 195 | } else { |
201 | Ty::Unknown | 196 | Ty::Unknown |
202 | } | 197 | }; |
198 | |||
199 | Ty::apply_one(TypeCtor::Slice, ty) | ||
203 | } | 200 | } |
204 | _ => Ty::Unknown, | 201 | _ => Ty::Unknown, |
205 | }; | 202 | }; |
diff --git a/crates/ra_hir_ty/src/tests/patterns.rs b/crates/ra_hir_ty/src/tests/patterns.rs index 6a9413521..d8e95112f 100644 --- a/crates/ra_hir_ty/src/tests/patterns.rs +++ b/crates/ra_hir_ty/src/tests/patterns.rs | |||
@@ -53,8 +53,8 @@ fn test(x: &i32) { | |||
53 | [140; 141) 'g': {unknown} | 53 | [140; 141) 'g': {unknown} |
54 | [144; 145) 'e': {unknown} | 54 | [144; 145) 'e': {unknown} |
55 | [158; 205) 'if let... }': () | 55 | [158; 205) 'if let... }': () |
56 | [165; 170) '[val]': {unknown} | 56 | [165; 170) '[val]': [{unknown}] |
57 | [173; 176) 'opt': {unknown} | 57 | [173; 176) 'opt': [{unknown}] |
58 | [177; 205) '{ ... }': () | 58 | [177; 205) '{ ... }': () |
59 | [191; 192) 'h': {unknown} | 59 | [191; 192) 'h': {unknown} |
60 | [195; 198) 'val': {unknown} | 60 | [195; 198) 'val': {unknown} |