1
Fork 0

fix ~ZeroSizeType rvalues

Closes #13360
This commit is contained in:
Daniel Micay 2014-04-07 12:36:36 -04:00 committed by Alex Crichton
parent cced02fcac
commit de2567dec9
2 changed files with 19 additions and 2 deletions

View file

@ -1802,11 +1802,15 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
RvalueExpr(Rvalue { mode: ByRef }) => {
let scope = cleanup::temporary_scope(bcx.tcx(), expr.id);
let ptr = Load(bcx, datum.val);
bcx.fcx.schedule_free_value(scope, ptr, cleanup::HeapExchange);
if !type_is_zero_size(bcx.ccx(), content_ty) {
bcx.fcx.schedule_free_value(scope, ptr, cleanup::HeapExchange);
}
}
RvalueExpr(Rvalue { mode: ByValue }) => {
let scope = cleanup::temporary_scope(bcx.tcx(), expr.id);
bcx.fcx.schedule_free_value(scope, datum.val, cleanup::HeapExchange);
if !type_is_zero_size(bcx.ccx(), content_ty) {
bcx.fcx.schedule_free_value(scope, datum.val, cleanup::HeapExchange);
}
}
LvalueExpr => { }
}

View file

@ -0,0 +1,13 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn main() {
let x = *~();
}