From 2cdd1ff1b50b7c71e9f8aaf03a58501a4af97dce Mon Sep 17 00:00:00 2001 From: cynecx Date: Sun, 28 Feb 2021 21:15:26 +0100 Subject: hir_ty: use default type generic for box expressions --- crates/hir_ty/src/infer/expr.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/hir_ty/src/infer/expr.rs') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 13240f790..98bc23173 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -488,6 +488,12 @@ impl<'a> InferenceContext<'a> { if let Some(box_) = self.resolve_boxed_box() { let mut sb = Substs::builder(generics(self.db.upcast(), box_.into()).len()); sb = sb.push(inner_ty); + match self.db.generic_defaults(box_.into()).as_ref() { + [_, alloc_ty, ..] if !alloc_ty.value.is_unknown() => { + sb = sb.push(alloc_ty.value.clone()); + } + _ => (), + } sb = sb.fill(repeat_with(|| self.table.new_type_var())); Ty::Adt(box_, sb.build()) } else { -- cgit v1.2.3