Code
I tried this code:
// add.rs
pub fn main() {
let x = add();
println!("1 + 2 = {x}")
}
fn add() -> i32 {
let x = 1;
let y = 2;
x + y
}
Running rustc add.rs --emit mir produces different results.
I expected to see this happen (version info: rustc 1.68.0-nightly (afaf3e0 2023-01-14)) :
bb0: {
_1 = const 1_i32; // scope 0 at assignments.rs:7:13: 7:14
_2 = const 2_i32; // scope 1 at assignments.rs:8:13: 8:14
_0 = const 3_i32; // scope 2 at assignments.rs:9:5: 9:10
return; // scope 0 at assignments.rs:10:2: 10:2
}
Instead, this happened (version info: rustc 1.72.0-nightly (fe7454b 2023-06-19))
bb0: {
_1 = const 1_i32;
_2 = const 2_i32;
_3 = CheckedAdd(_1, _2);
assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", _1, _2) -> bb1;
}
bb1: {
_0 = move (_3.0: i32);
return;
}
It seems ConstProp is removed from the newer rustc versions, by looking into dumped mir in the nightly build (version 1.68 and 1.72).
Is this change permanent? or if anyone could explain the reasons of removing? Thank you.
Code
I tried this code:
Running
rustc add.rs --emit mirproduces different results.I expected to see this happen (
version info: rustc 1.68.0-nightly (afaf3e0 2023-01-14)) :Instead, this happened (
version info: rustc 1.72.0-nightly (fe7454b 2023-06-19))It seems
ConstPropis removed from the newer rustc versions, by looking into dumped mir in the nightly build (version 1.68 and 1.72).Is this change permanent? or if anyone could explain the reasons of removing? Thank you.