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

Negative coverage: loan_cannot_outlive_universal_regions / loan_not_required_by_universal_regions / premise if outlived_by_loan.iter().all(\|p\| match p { // If ’0: Tthen’0must hold for entire fn body... Parameter::Ty(_) => false, Parameter::Lt(lt) => match lt.as_ref() { // If’0: ’staticthen’0must hold for entire fn body... Lt::Static => false, // If’0: ’afor some lifetime parameter’a, then ’0must hold for entire fn body... Lt::Variable(Variable::UniversalVar(_)) => false, // If’0: ’1, that's fine. Lt::Variable(Variable::ExistentialVar(_)) => true, Lt::Variable(Variable::BoundVar(_)) => panic!("cannot outlive a bound var"), // Erased lifetimes are used in codegen; treat like existential. Lt::Erased => true, }, // Not really clear what this would mean Parameter::Const(_) => panic!("cannot outlive a constant"), })

Premise at line 1197. Observed failure causes: if_false.

loan_not_required_by_universal_regions
LineCoverageSource
1196N/A(let outlived_by_loan = transitively_outlived_by(&env, &outlives, &loan.lt))
11975(if outlived_by_loan.iter().all(|p| match p {
// If `'0: T` then `'0` must hold for entire fn body...
Parameter::Ty(_) => false,

Parameter::Lt(lt) => match lt.as_ref() {
// If `'0: 'static` then `'0` must hold for entire fn body...
Lt::Static => false,

// If `'0: 'a` for some lifetime parameter `'a`, then `'0` must hold for entire fn body...
Lt::Variable(Variable::UniversalVar(_)) => false,

// If `'0: '1`, that's fine.
Lt::Variable(Variable::ExistentialVar(_)) => true,

Lt::Variable(Variable::BoundVar(_)) => panic!("cannot outlive a bound var"),

// Erased lifetimes are used in codegen; treat like existential.
Lt::Erased => true,
},

// Not really clear what this would mean
Parameter::Const(_) => panic!("cannot outlive a constant"),
}))
──────── ("loan_not_required_by_universal_regions")
122115(loan_cannot_outlive_universal_regions(env, _assumptions, outlives, loan) => ())

5 tests failed proving this premise:


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

fn min_problem_case_3<'a>(m: &'a mut Map) -> &'a mut Map {
    exists<'r0, 'r1> {
        let n: &'r0 mut Map = &'r0 mut *m;
        if true {
            return n;
        } else {
            let o: &'r1 mut Map = &'r1 mut *m;
            return o;
        }
    }
}
Failed proof tree

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

fn foo<'a>(m: &'a mut Map) -> &'a mut Map {
    exists<'r0, 'r1> {
        let n: &'r0 mut Map = &'r0 mut *m;
        if false {
            return n;
        } else {
            let o: &'r1 mut Map = &'r1 mut *m;
            return o;
        }
    }
}
Failed proof tree

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

fn reborrow<'a>(a: &'a mut u8) -> &'a mut u8 {
    exists<'r0, 'r1, 'r2, 'r3> {
        // This creates an outlives constraint
        let b: &'r1 mut u8 = &'r0 mut *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: &'r3 mut u8 = &'r2 mut *a;
        return c;
    }
}
Failed proof tree

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

fn next<'a>(d: &'a mut Decoder) -> &'a u32 {
    exists<'r0, 'r1> {
        'l: loop {
            let buf: &'r0 u32 = fill_buf::<'r0>(&'r0 mut (*d).buf_read);
            let s: &'r1 u32 = decode::<'r1>(buf);
            if true {
                return s;
            } else {
            }
        }
    }
}
Failed proof tree

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>();
    }
}
Failed proof tree