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 / break

break
LineCoverageSource
256(if state.scope_has_label(label))
257N/A(let locals_to_drop = state.locals_dropped_to_label(label))
2582(drop_places(env, assumptions, state, locals_to_drop, places_live_on_exit) => state)
259N/A(let state = state.with_break(label))
260N/A(let state = state.diverges())
──────── ("break")
26217(borrow_check_statement(env, assumptions, state, Stmt::Break { label }, places_live_on_exit) => (env, state))

17 tests exercised this rule:


Source location: tests/borrowck.rs:3855 (all coverage from this test)

fn remove_last_node_iterative<'a>(node: &'a mut List) -> u32 {
    exists<'r0, 'r1> {
        let cursor: &'r0 mut List = &'r0 mut *node;
        'l: loop {
            let next: &'r1 mut List = &'r1 mut *cursor;
            if true {
                cursor = next;
            } else {
                break 'l;
            }
        }
        *cursor = List { value: 0_u32 };
        return 0_u32;
    }
}
Proof tree
… (200 of 1847 nodes shown)

Source location: tests/borrowck.rs:3917 (all coverage from this test)

fn no_control_flow() -> u32 {
    exists<'r0, 'r1, 'r2, 'r3> {
        let b: X = X { value: 0_u32 };
        let p: &'r0 mut X = &'r1 mut b;
        'l: loop {
            let now: &'r2 mut X = &'r2 mut *p;
            if true {
                let next: &'r3 mut X = next_of::<'r3>(&'r3 mut *now);
                p = next;
            } else {
                break 'l;
            }
        }
        return 0_u32;
    }
}
Proof tree
… (200 of 2276 nodes shown)

Source location: tests/borrowck.rs:3967 (all coverage from this test)

fn conditional() -> u32 {
    exists<'r0, 'r1, 'r2, 'r3> {
        let b: X = X { value: 0_u32 };
        let p: &'r0 mut X = &'r1 mut b;
        'l: loop {
            let now: &'r2 mut X = &'r2 mut *p;
            if true {
                if true {
                    let next: &'r3 mut X = next_of::<'r3>(&'r3 mut *now);
                    p = next;
                } else {
                }
            } else {
                break 'l;
            }
        }
        return 0_u32;
    }
}
Proof tree
… (200 of 2332 nodes shown)

Source location: tests/borrowck.rs:4056 (all coverage from this test)

fn conditional_with_indirection() -> u32 {
    exists<'r0, 'r1, 'r2, 'r3> {
        let b: X = X { value: 0_u32 };
        let p: &'r0 mut X = &'r1 mut b;
        'l: loop {
            let now: &'r2 mut X = &'r2 mut *p;
            if true {
                if true {
                    let next: &'r3 mut X = next_of::<'r3>(&'r3 mut *p);
                    p = next;
                } else {
                }
            } else {
                break 'l;
            }
        }
        return 0_u32;
    }
}
Proof tree
… (200 of 2450 nodes shown)

Source location: tests/borrowck.rs:4143 (all coverage from this test)

fn to_refs2<'a>(list: &'a mut List) -> &'a mut u32 {
    exists<'r0, 'r1> {
        let result: &'a mut u32;
        'l: loop {
            result = &'r0 mut (*list).value;
            if true {
                let n: &'r1 mut List = next_from_field::<'r1>(&'r1 mut (*list).next);
                list = n;
            } else {
                break 'l;
            }
        }
        return result;
    }
}
Proof tree
… (200 of 2021 nodes shown)

Source location: tests/borrowck.rs:4356 (all coverage from this test)

fn next<'s>(f: &'s mut Filter) -> &'s mut u32 {
    exists<'r0, 'r1, 'r2> {
        'l: loop {
            let item: &'r0 mut u32 = iter_next::<'r0>(&'r0 mut (*f).iter);
            if true {
                let keep: bool = call_predicate::<'r1, 'r2>(&'r1 mut (*f).predicate, &'r2 *item);
                if keep {
                    return item;
                } else {
                }
            } else {
                break 'l;
            }
        }
        return no_item::<'s>();
    }
}
Proof tree
… (200 of 2783 nodes shown)

Source location: tests/codegen.rs:110 (all coverage from this test)

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 (all coverage from this test)

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 (all coverage from this test)

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 (all coverage from this test)

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 (all coverage from this test)

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 trees omitted for the remaining 7 tests; each one is on its test’s page in Coverage by test.


Source location: tests/codegen.rs:443 (all coverage from this test)

fn main() -> () {
    let x: i32 = 0_i32;
    'a: loop {
        x = 77_i32;
        break 'a;
    }
    println!(x);
}

Source location: tests/codegen.rs:461 (all coverage from this test)

fn main() -> () {
    let x: i32 = 0_i32;
    'a: loop {
        {
            x = 88_i32;
            break 'a;
        }
    }
    println!(x);
}

Source location: tests/codegen.rs:477 (all coverage from this test)

fn main() -> () {
    'a: {
        println!(1_i32);
        break 'a;
        println!(2_i32);
    }
    println!(3_i32);
}

Source location: tests/mir_typeck.rs:988 (all coverage from this test)

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

Source location: tests/mir_typeck.rs:1142 (all coverage from this test)

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

Source location: tests/return_validation.rs:118 (all coverage from this test)

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