Is it a bug in Rust compiler or in LLVM?



I’m trying to use VSCode for interactive debugging of a Rust code. When I debug a code like following I can see values of the x and y variables only in the first block but not in the second. Within the second block the x and y variables are still shown as Variable is optimized away and not available.

    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("Failed to read line");
    let mut iter = input.split_whitespace();

    let mut desk = {
        let x: i32 =;
        let y: i32 =;
        knights::Desk::new(x, y)

    let start;
    let res = {
        let x: i32 =;
        let y: i32 =;
        start = Instant::now();
        desk.find_first(x, y)

The full code could be found in this topic:


First, do you debug a release or debug build?

Second, it’s probably not exactly a bug in either. Compilers sometimes notice some variables are not needed (they can rewrite the code without them) and simply throw them away. Then you can’t see their value. It’s unfortunate, but it usually happens only in release (optimised) builds.


A debug build, so those variables should not be thrown away (optimized).