aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer/pat.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer/pat.rs')
-rw-r--r--crates/hir_ty/src/infer/pat.rs26
1 files changed, 7 insertions, 19 deletions
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs
index 10df8d8cb..5b70d5e5a 100644
--- a/crates/hir_ty/src/infer/pat.rs
+++ b/crates/hir_ty/src/infer/pat.rs
@@ -13,9 +13,8 @@ use hir_expand::name::Name;
13 13
14use super::{BindingMode, Expectation, InferenceContext}; 14use super::{BindingMode, Expectation, InferenceContext};
15use crate::{ 15use crate::{
16 lower::lower_to_chalk_mutability, 16 lower::lower_to_chalk_mutability, utils::variant_data, Interner, Substitution, Ty, TyBuilder,
17 utils::{generics, variant_data}, 17 TyKind,
18 Interner, Substitution, Ty, TyKind,
19}; 18};
20 19
21impl<'a> InferenceContext<'a> { 20impl<'a> InferenceContext<'a> {
@@ -246,23 +245,12 @@ impl<'a> InferenceContext<'a> {
246 }; 245 };
247 246
248 let inner_ty = self.infer_pat(*inner, &inner_ty, default_bm); 247 let inner_ty = self.infer_pat(*inner, &inner_ty, default_bm);
249 let mut sb = Substitution::build_for_generics(&generics( 248 let mut b = TyBuilder::adt(self.db, box_adt).push(inner_ty);
250 self.db.upcast(), 249
251 box_adt.into(), 250 if let Some(alloc_ty) = alloc_ty {
252 )); 251 b = b.push(alloc_ty);
253 sb = sb.push(inner_ty);
254 if sb.remaining() == 1 {
255 sb = sb.push(match alloc_ty {
256 Some(alloc_ty) if !alloc_ty.is_unknown() => alloc_ty,
257 _ => match self.db.generic_defaults(box_adt.into()).get(1) {
258 Some(alloc_ty) if !alloc_ty.value.is_unknown() => {
259 alloc_ty.value.clone()
260 }
261 _ => self.table.new_type_var(),
262 },
263 });
264 } 252 }
265 Ty::adt_ty(box_adt, sb.build()) 253 b.fill_with_defaults(self.db, || self.table.new_type_var()).build()
266 } 254 }
267 None => self.err_ty(), 255 None => self.err_ty(),
268 }, 256 },