Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Positive coverage: borrow_check_statement / loop

loop
LineCoverageSource
244N/A(let continue_live = Stmt::loop_(label, body).live_before(&env, &state, places_live_on_exit))
245(let state = state.push_continue_scope(&env.env, label, places_live_on_exit, continue_live)?)
2466(borrow_check_loop(env, assumptions, state, body, places_live_on_exit) => state)
247N/A(let state = state.pop_scope(label))
──────── ("loop")
24913(borrow_check_statement(env, assumptions, state, Stmt::Loop { label, body }, places_live_on_exit) => (env, state))

13 tests exercised this rule:


Source location: tests/borrowck.rs:2600

fn foo() -> u32 {
    exists<'r0, 'r1> {
        'a: loop {
            let x: i32 = 0 _ i32;
            let r: &'r0 i32 = &'r1 x;
            let _y: i32 = *r;
            continue 'a;
        }
    }
}
Proof tree
… (200 of 1443 nodes shown)

Source location: tests/codegen.rs:110

fn main() -> () {
    let x: i32 = 0 _ i32;
    'a: loop {
        println!(x);
        break 'a;
    }
}
Proof tree
… (200 of 1037 nodes shown)

Source location: tests/codegen.rs:318

fn main() -> () {
    let x: i32 = 0 _ i32;
    'a: loop {
        if true {
            println!(x);
            break 'a;
        } else {
            continue 'a;
        }
    }
}
Proof tree
… (200 of 1073 nodes shown)

Source location: tests/codegen.rs:336

fn main() -> () {
    'outer: loop {
        println!(1 _ i32);
        'inner: loop {
            println!(2 _ i32);
            break 'outer;
        }
    }
    println!(3 _ i32);
}
Proof tree
… (200 of 1039 nodes shown)

Source location: tests/codegen.rs:356

fn main() -> () {
    'a: loop {
        if true {
            println!(1 _ i32);
            break 'a;
        } else {
            println!(2 _ i32);
            break 'a;
        }
    }
    println!(3 _ i32);
}
Proof tree
… (200 of 1053 nodes shown)

Source location: tests/codegen.rs:377

fn main() -> () {
    let x: i32 = 0 _ i32;
    'a: loop {
        if false {
            x = 1 _ i32;
            break 'a;
        } else {
            x = 2 _ i32;
            break 'a;
        }
    }
    println!(x);
}
Proof tree
… (200 of 1113 nodes shown)

Source location: tests/codegen.rs:443

fn main() -> () {
    let x: i32 = 0 _ i32;
    'a: loop {
        x = 77 _ i32;
        break 'a;
    }
    println!(x);
}
Proof tree
… (200 of 1053 nodes shown)

Source location: tests/codegen.rs:461

fn main() -> () {
    let x: i32 = 0 _ i32;
    'a: loop {
        {
            x = 88 _ i32;
            break 'a;
        }
    }
    println!(x);
}
Proof tree
… (200 of 1063 nodes shown)

Source location: tests/mir_typeck.rs:105

fn foo() -> u32 {
    let v0: u32 = 0 _ u32;
    loop {
        v0 = v0;
    }
}
Proof tree
… (200 of 1028 nodes shown)

Source location: tests/mir_typeck.rs:755

fn foo() -> u32 {
    'a: loop {
        break 'a;
    }
    return 0 _ u32;
}
Proof tree
… (200 of 1010 nodes shown)

Source location: tests/mir_typeck.rs:802

fn foo() -> u32 {
    'a: loop {
        continue 'a;
    }
    return 0 _ u32;
}

Proof trees omitted for the remaining 3 tests.


Source location: tests/return_validation.rs:79

fn foo() -> u32 {
    loop {
    }
}

Source location: tests/return_validation.rs:111

fn foo() -> u32 {
    'a: loop {
        break 'a;
    }
    return 0 _ u32;
}