Handle box with allocator

In 1.49.0, the definition of Box was modified to support an optional
Allocator[1]. Adapt the parsing of the `box` keyword to supply the
expected number of parameters to the constructor.

[1] f288cd2e17
This commit is contained in:
Thiébaud Weksteen 2021-01-22 11:17:45 +01:00
parent fde4a860ae
commit be0691b02b
2 changed files with 28 additions and 1 deletions

View file

@ -491,7 +491,10 @@ impl<'a> InferenceContext<'a> {
Expr::Box { expr } => {
let inner_ty = self.infer_expr_inner(*expr, &Expectation::none());
if let Some(box_) = self.resolve_boxed_box() {
Ty::apply_one(TypeCtor::Adt(box_), inner_ty)
let mut sb = Substs::build_for_type_ctor(self.db, TypeCtor::Adt(box_));
sb = sb.push(inner_ty);
sb = sb.fill(repeat_with(|| self.table.new_type_var()));
Ty::apply(TypeCtor::Adt(box_), sb.build())
} else {
Ty::Unknown
}