Closed
Description
The const prop pass handles propagation into temporaries correctly but doesn't propagate temporaries into user defined variables.
fn main() {
let x = 2 + 2;
}
currently compiles to the following MIR:
fn main() -> () {
let mut _0: ();
let _1: i32;
let mut _2: (i32, bool);
scope 1 {
}
bb0: {
StorageLive(_1);
(_2.0: i32) = const 4i32;
(_2.1: bool) = const false;
_1 = move (_2.0: i32);
StorageDead(_1);
return;
}
}
but should ideally compile to:
fn main() -> () {
let mut _0: ();
let _1: i32;
scope 1 {
}
bb0: {
StorageLive(_1);
_1 = const 4i32;
StorageDead(_1);
return;
}
}