diff options
author | adamrk <[email protected]> | 2020-06-25 22:05:55 +0100 |
---|---|---|
committer | adamrk <[email protected]> | 2020-06-25 22:16:58 +0100 |
commit | 0ebc24043bb267cf77ddd6c1d8b7d5ad9f82444d (patch) | |
tree | f311230e61cfb4014e0332a6abe701b7a0d19594 /crates/ra_hir_ty/src/infer | |
parent | 3615347fcebebaa58a5cbf675ae062aae149d9c3 (diff) |
Infer type for slice wildcard patterns
Diffstat (limited to 'crates/ra_hir_ty/src/infer')
-rw-r--r-- | crates/ra_hir_ty/src/infer/pat.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index 23de2bd6b..4dd4f9802 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs | |||
@@ -184,7 +184,7 @@ impl<'a> InferenceContext<'a> { | |||
184 | self.write_pat_ty(pat, bound_ty); | 184 | self.write_pat_ty(pat, bound_ty); |
185 | return inner_ty; | 185 | return inner_ty; |
186 | } | 186 | } |
187 | Pat::Slice { prefix, slice: _slice, suffix } => { | 187 | Pat::Slice { prefix, slice, suffix } => { |
188 | let (container_ty, elem_ty) = match &expected { | 188 | let (container_ty, elem_ty) = match &expected { |
189 | ty_app!(TypeCtor::Array, st) => (TypeCtor::Array, st.as_single().clone()), | 189 | ty_app!(TypeCtor::Array, st) => (TypeCtor::Array, st.as_single().clone()), |
190 | ty_app!(TypeCtor::Slice, st) => (TypeCtor::Slice, st.as_single().clone()), | 190 | ty_app!(TypeCtor::Slice, st) => (TypeCtor::Slice, st.as_single().clone()), |
@@ -195,7 +195,12 @@ impl<'a> InferenceContext<'a> { | |||
195 | self.infer_pat(*pat_id, &elem_ty, default_bm); | 195 | self.infer_pat(*pat_id, &elem_ty, default_bm); |
196 | } | 196 | } |
197 | 197 | ||
198 | Ty::apply_one(container_ty, elem_ty) | 198 | let pat_ty = Ty::apply_one(container_ty, elem_ty); |
199 | if let Some(slice_pat_id) = slice { | ||
200 | self.infer_pat(*slice_pat_id, &pat_ty, default_bm); | ||
201 | } | ||
202 | |||
203 | pat_ty | ||
199 | } | 204 | } |
200 | Pat::Wild => expected.clone(), | 205 | Pat::Wild => expected.clone(), |
201 | Pat::Range { start, end } => { | 206 | Pat::Range { start, end } => { |