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

call
LineCoverageSource
4203(borrow_check_expr(
env,
assumptions,
state,
callee,
args.live_before(env, &state, places_live),
) => (callee_ty, state))
429(prove_ty_is_rigid(env, assumptions, state, callee_ty) => (RigidTy { name: RigidName::FnDef(fn_id), parameters }, state))
432(let Fn { id: _, safety, binder } = env.crates().fn_named(fn_id)?)
434(ProvenSet::singleton((safety, ProofTree::leaf("safety"))) => Safety::Safe)
435(let FnBoundData { input_args, output_ty, where_clauses, body: _ } =
binder.instantiate_with(parameters)?)
439N/A(let input_tys: Vec<Ty> = input_args.iter().map(|a| a.ty.clone()).collect())
4401(if input_tys.len() == args.len())
442(for_all(i in 0..args.len()) with(state)
(borrow_check_expr_has_ty(env, assumptions, state, &args[i], &input_tys[i], places_live) => state))
4452(prove_where_clauses(env, assumptions, state, where_clauses) => state)
──────── ("call")
44725(borrow_check_expr(env, assumptions, state, Expr::Call { callee, args }, places_live) => (output_ty, state))

25 tests exercised this rule:


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

fn foo<'a>(a: &'a u32) -> &'a u32 {
    exists<'r0> {
        let r: &'r0 u32 = identity::<&'r0 u32>(a);
        return r;
    }
}
Proof tree
… (200 of 1140 nodes shown)

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

fn bar() -> u32 {
    exists<'r1> {
        let v: u32 = 7_u32;
        let r: u32 = foo::<'r1>(&'r1 v);
        return r;
    }
}
Proof tree
… (200 of 1229 nodes shown)

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

fn foo<'a, 'b>(a: &'a u32) -> &'b u32
where
    'a: 'b,
{
    let r: &'b u32 = identity::<&'b u32>(a);
    return r;
}
Proof tree
… (200 of 1133 nodes shown)

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

fn foo<'b>(a: &'b u32) -> &'b u32 {
    let r: &'b u32 = bar::<'b, &'b u32>(a);
    return r;
}
Proof tree
… (200 of 1136 nodes shown)

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

fn bar() -> u32 {
    exists<'r0, 'r1> {
        let v: u32 = 1_u32;
        let p: &'r0 u32 = &'r1 v;
        foo(0_u32);
        return *p;
    }
}
Proof tree
… (200 of 1239 nodes shown)

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

fn remove_last_node_recursive<'a>(node: &'a mut List) -> u32 {
    exists<'r0> {
        let next: &'r0 mut List = next_of::<'r0>(&'r0 mut *node);
        if true {
            remove_last_node_recursive::<'r0>(next);
        } else {
            *node = List { value: 0_u32 };
        }
        return 0_u32;
    }
}
Proof tree
… (200 of 1436 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:4108 (all coverage from this test)

fn to_refs<'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 {
                return result;
            }
        }
    }
}
Proof tree
… (200 of 1733 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 trees omitted for the remaining 15 tests; each one is on its test’s page in Coverage by test.


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

fn to_refs3<'a>(list: &'a mut List) -> &'a mut u32 {
    exists<'r0, 'r1> {
        let result: &'a mut u32;
        let cursor: &'a mut List = &'a mut *list;
        'l: loop {
            result = &'r0 mut (*cursor).value;
            if true {
                let n: &'r1 mut List = next_from_field::<'r1>(&'r1 mut (*cursor).next);
                cursor = n;
            } else {
                return result;
            }
        }
    }
}

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 {
            }
        }
    }
}

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

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

fn use_it<'a, 'b>() -> u32 {
    exists<'r0> {
        let v: Invariant<'r0> = create_invariant::<'r0>();
        if true {
            return sink::<'a, 'r0>(v);
        } else {
            return sink::<'b, 'r0>(v);
        }
    }
}

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

fn use_it_but_its_the_same_region<'a, 'b>() -> u32 where 'a: 'b, 'b: 'a {
    exists<'r0> {
        let v: Invariant<'r0> = create_invariant::<'r0>();
        if true {
            return sink::<'a, 'r0>(v);
        } else {
            return sink::<'b, 'r0>(v);
        }
    }
}

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

fn main() -> () {
    let y: i32 = add_one(1_i32);
    println!(y);
}

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

fn main() -> () {
    let y: i32 = identity::<i32>(42_i32);
    println!(y);
}

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

fn main() -> () {
    let a: i32 = f(1_i32);
    let b: i32 = f(2_i32);
    let c: i32 = f(3_i32);
    println!(a);
    println!(b);
    println!(c);
}

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

fn main() -> () {
    let y: i32 = f(f(42_i32));
    println!(y);
}

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

fn main() -> () {
    let r: i32 = outer(7_i32);
    println!(r);
}

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

fn main() -> () {
    a();
}

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

fn main() -> () {
    let r: i32 = first::<i32, bool>(10_i32, true);
    println!(r);
}

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

fn bar(v1: u32) -> u32 {
    let v0: u32 = foo(v1);
    return v0;
}

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

fn bar(v1: u32) -> u32 {
    let v0: u32 = identity::<u32>(v1);
    return v0;
}