initialize the destination in unit statements

Fixes #46159.
This commit is contained in:
Ariel Ben-Yehuda 2017-11-27 17:58:59 +02:00
parent af8c2339cf
commit a6e24fc31f
3 changed files with 5 additions and 1 deletions

View File

@ -273,7 +273,9 @@ pub fn into_expr(&mut self,
ExprKind::Break { .. } |
ExprKind::InlineAsm { .. } |
ExprKind::Return {.. } => {
this.stmt_expr(block, expr)
unpack!(block = this.stmt_expr(block, expr));
this.cfg.push_assign_unit(block, source_info, destination);
block.unit()
}
// these are the cases that are more naturally handled by some other mode

View File

@ -54,6 +54,7 @@ fn main() {
// Validate(Acquire, [_1: &ReFree(DefId(0/1:9 ~ validate_4[317d]::write_42[0]::{{closure}}[0]), BrEnv) [closure@NodeId(22)], _2: *mut i32]);
// Validate(Release, [_1: &ReFree(DefId(0/1:9 ~ validate_4[317d]::write_42[0]::{{closure}}[0]), BrEnv) [closure@NodeId(22)], _2: *mut i32]);
// (*_2) = const 23i32;
// _0 = ();
// return;
// }
// }

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: -Z borrowck=compare
use std::cell::Cell;
use std::mem::swap;