Closed
Description
On the last Nightly:
rustc 1.42.0-nightly (c5840f9d2 2020-01-03)
binary: rustc
commit-hash: c5840f9d252c2f5cc16698dbf385a29c5de3ca07
commit-date: 2020-01-03
host: x86_64-pc-windows-gnu
release: 1.42.0-nightly
LLVM version: 9.0
rustc -Z mir-opt-level=1 test.rs => OK
rustc -Z mir-opt-level=2 test.rs => Error
fn e220() -> String {
fn get_displacement(mut distance: i64, generation: i32) -> [i64; 4] {
if generation == 0 {
return match distance {
0 => [0, 1, 0, 0],
1 => [0, 1, 0, 1],
_ => panic!("Travel past end")
}
}
let half_len = 1i64 << (generation - 1);
let second_half = distance > half_len;
if second_half {
distance = half_len + half_len - distance;
}
let mut ret = get_displacement(distance, generation - 1);
let (ex, ey) = (ret[0], ret[1]);
ret[0] = ex + ey;
ret[1] = ey - ex;
if second_half {
let (px, py) = (ret[2], ret[3]);
ret[2] = ex + ey - py;
ret[3] = ey - ex + px;
}
ret
}
let res = get_displacement(1_000_000_000_000, 50);
format!("{},{}", res[2], res[3])
}
fn main() {
assert_eq!(e220(), "139776,963904");
}