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_expr / true

true
LineCoverageSource
──────── ("true")
42513(borrow_check_expr(_env, _assumptions, state, Expr::True, _places_live_on_exit) => (ScalarId::Bool, state))

13 tests exercised this rule:


Source location: tests/borrowck.rs:186

fn foo() -> u32 {
    let x: u32;
    if true {
        x = 1 _ u32;
    } else {
        x = 2 _ u32;
    }
    return x;
}
Proof tree
… (200 of 1048 nodes shown)

Source location: tests/borrowck.rs:1968

fn min_problem_case_3<'a>(m: &mut 'a Map) -> &mut 'a Map {
    exists<'r0, 'r1> {
        let n: &mut 'r0 Map = &mut 'r0 *m;
        if true {
            return n;
        } else {
            let o: &mut 'r1 Map = &mut 'r1 *m;
            return o;
        }
    }
}
Proof tree
… (200 of 1324 nodes shown)

Source location: tests/borrowck.rs:2156

fn min_problem_case_3<'a>(m: &mut 'a Map) -> &mut 'a Map {
    exists<'r0, 'r1> {
        let n: &mut 'r0 Map = &mut 'r0 *m;
        if true {
        } else {
        }
        let o: &mut 'r1 Map = &mut 'r1 *m;
        return o;
    }
}
Proof tree
… (200 of 1295 nodes shown)

Source location: tests/borrowck.rs:2410

fn foo () -> u32 {
    exists<'l_p, 'l_q, 'loan_0, 'loan_1, 'loan_2, 'loan_3> {
        let a: u32 = 0 _ u32;
        let b: u32 = 0 _ u32;
        // In Rustc, the 1-tuple is needed for some reason
        // Niko does not 100% understand, else rustc is able to
        // see that this program is safe.
        let q: &mut 'l_q u32 = &mut 'loan_0 a;
        let p: &mut 'l_p u32 = &mut 'loan_1 a;
        if true {
            p = &mut 'loan_1 a;
            q = &mut 'loan_2 b;
        } else {
            p = &mut 'loan_3 b;
        }
        *q = 1 _ u32;
        return *p;
    }
}
Proof tree
… (200 of 1495 nodes shown)

Source location: tests/borrowck.rs:3095

fn reborrow<'a>(a: &mut 'a u8) -> &mut 'a u8 {
    exists<'r0, 'r1, 'r2, 'r3> {
        if true {
            let b: &mut 'r1 u8 = &mut 'r0 *a;
            return b;
        } else { }

        let c: &mut 'r3 u8 = &mut 'r2 *a;
        return c;
    }
}
Proof tree
… (200 of 1308 nodes shown)

Source location: tests/borrowck.rs:3120

fn reborrow<'a>(a: &mut 'a u8) -> &mut 'a u8 {
    exists<'r0, 'r1, 'r2, 'r3> {
        // This creates an outlives constraint
        let b: &mut 'r1 u8 = &mut 'r0 *a;
        if true {
            return b;
        } else {
            // this means the loan remains live
        }

        // If the outlives constraint propagated here,
        // we would get an error.
        let c: &mut 'r3 u8 = &mut 'r2 *a;
        return c;
    }
}
Proof tree
… (200 of 1314 nodes shown)

Source location: tests/borrowck.rs:3157

fn reborrow<'a>(a: &mut 'a u8) -> &mut 'a u8 {
    exists<'r0, 'r1, 'r2, 'r3> {
        if true {
            let b: &mut 'r1 u8 = &mut 'r0 *a;
            return b;
        } else {
            let c: &mut 'r3 u8 = &mut 'r2 *a;
            return c;
        }
    }
}
Proof tree
… (200 of 1309 nodes shown)

Source location: tests/codegen.rs:24

fn main() -> () {
    println!(1 _ i32);
    println!(true);
    println!(false);
}
Proof tree
… (200 of 995 nodes shown)

Source location: tests/codegen.rs:95

fn main() -> () {
    let x: i32 = 1 _ i32;
    if true {
        println!(x);
    } else {
        println!(0 _ i32);
    }
}
Proof tree
… (200 of 1031 nodes shown)

Source location: tests/codegen.rs:251

fn main() -> () {
    let r: i32 = first::<i32, bool>(10 _ i32, true);
    println!(r);
}
Proof tree
… (200 of 1074 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 trees omitted for the remaining 3 tests.


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);
}

Source location: tests/mir_typeck.rs:117

fn foo () -> bool {
    return true;
}