]> git.lizzy.rs Git - rust.git/commitdiff
[MIR] Fix type of temporary for `box EXPR`
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Fri, 29 Jan 2016 14:44:16 +0000 (15:44 +0100)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Fri, 29 Jan 2016 15:13:31 +0000 (16:13 +0100)
Previously the code would fail to dereference the temporary.

src/librustc_mir/build/expr/as_rvalue.rs

index c389e8e7330917f7d88dba8fce39998b93d1e2ac..e556d707a2d48d27ac68eae1a7defdce785b7e64 100644 (file)
@@ -61,16 +61,15 @@ fn expr_as_rvalue(&mut self,
             }
             ExprKind::Box { value } => {
                 let value = this.hir.mirror(value);
-                let value_ty = value.ty.clone();
-                let result = this.temp(value_ty.clone());
+                let result = this.temp(expr.ty);
 
                 // to start, malloc some memory of suitable type (thus far, uninitialized):
-                let rvalue = Rvalue::Box(value.ty.clone());
+                let rvalue = Rvalue::Box(value.ty);
                 this.cfg.push_assign(block, expr_span, &result, rvalue);
 
                 // schedule a shallow free of that memory, lest we unwind:
                 let extent = this.extent_of_innermost_scope();
-                this.schedule_drop(expr_span, extent, DropKind::Free, &result, value_ty);
+                this.schedule_drop(expr_span, extent, DropKind::Free, &result, value.ty);
 
                 // initialize the box contents:
                 let contents = result.clone().deref();