Skip to content

Commit 06ef2e7

Browse files
committed
[MIR] Fix type of temporary for box EXPR
Previously the code would fail to dereference the temporary.
1 parent 7bd87c1 commit 06ef2e7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/librustc_mir/build/expr/as_rvalue.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,15 @@ impl<'a,'tcx> Builder<'a,'tcx> {
6161
}
6262
ExprKind::Box { value } => {
6363
let value = this.hir.mirror(value);
64-
let value_ty = value.ty.clone();
65-
let result = this.temp(value_ty.clone());
64+
let result = this.temp(expr.ty);
6665

6766
// to start, malloc some memory of suitable type (thus far, uninitialized):
68-
let rvalue = Rvalue::Box(value.ty.clone());
67+
let rvalue = Rvalue::Box(value.ty);
6968
this.cfg.push_assign(block, expr_span, &result, rvalue);
7069

7170
// schedule a shallow free of that memory, lest we unwind:
7271
let extent = this.extent_of_innermost_scope();
73-
this.schedule_drop(expr_span, extent, DropKind::Free, &result, value_ty);
72+
this.schedule_drop(expr_span, extent, DropKind::Free, &result, value.ty);
7473

7574
// initialize the box contents:
7675
let contents = result.clone().deref();

0 commit comments

Comments
 (0)