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 / fn-name

fn-name
LineCoverageSource
557✗(if let PlaceExpr::Var(id) = place)
558✗(if !state.has_local(id))
5592(borrow_check_fn_ref(env, assumptions, state, id, Vec::<Parameter>::new()) => (ty, state))
──────── ("fn-name")
56114(borrow_check_expr(env, assumptions, state, Expr::Place(place), _places_live_on_exit) => (ty, state))

14 tests exercised this rule:


Source location: tests/borrowck.rs:3514 (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 3633 nodes shown)

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

fn main() -> () {
    let y: i32 = add_one(1_i32);
    println!(y);
}
Proof tree
… (200 of 3451 nodes shown)

Source location: tests/codegen.rs:282 (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);
}
Proof tree
… (200 of 3527 nodes shown)

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

fn main() -> () {
    let y: i32 = f(f(42_i32));
    println!(y);
}
Proof tree
… (200 of 3465 nodes shown)

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

fn main() -> () {
    let r: i32 = outer(7_i32);
    println!(r);
}
Proof tree
… (200 of 3523 nodes shown)

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

fn main() -> () {
    a();
}
Proof tree
… (200 of 3547 nodes shown)

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

fn main() -> () { println!(left() + right()); }
}])
tc_ok()
ect_output("1\n2\n30\n")
)
}

#[test]
ion_in_call_arguments() {
alityTest::new(crates![crate test {
fn sum(x: i32, y: i32) -> i32 { return x + y; }
fn main() -> () {
    println!(sum(1_i32 + 2_i32, sum(3_i32, 4_i32)));
}
Proof tree
… (200 of 3452 nodes shown)

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

fn main() -> () {
    println!(sum(1_i32 + 2_i32, sum(3_i32, 4_i32)));
}
Proof tree
… (200 of 3488 nodes shown)

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

fn main() -> () {
    let s: S = S { b: second(), a: first() };
    println!(s.a);
    println!(s.b);
}
Proof tree
… (200 of 3521 nodes shown)

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

fn main() -> () { println!(left() - right()); }
}])
tc_ok()
ect_output("1\n2\n7\n")
);
}

#[test]
er_subtraction_unsigned() {
alityTest::new(crates![crate Foo {
fn main() -> () {
    println!(10_u32 - 3_u32);
}
Proof tree
… (200 of 3452 nodes shown)

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

fn main() -> () { println!(left() * right()); }
}])
tc_ok()
ect_output("1\n2\n12\n")
);
}

#[test]
plication_with_parentheses() {
alityTest::new(crates![crate Foo {
fn main() -> () {
    println!((2_i32 + 3_i32) * 4_i32);
    println!(2_i32 * (3_i32 + 4_i32));
}

Proof trees omitted for the remaining 4 tests; each one is on its test’s page in Coverage by test.


Source location: tests/functions.rs:70 (all coverage from this test)

fn main() {
    helper();
}

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

fn main() -> () { require; }
}])
tc_ok()
);
}

#[test]
fn_value_with_forwarded_lifetime_bound() {
alityTest::new(crates![crate Foo {
fn require<'a, 'b>() -> () where 'a: 'b {}
fn outer<'a, 'b>() -> () where 'a: 'b { require::<'a, 'b>; }
fn main() -> () { outer::<'static, 'static>(); }
}])
tc_ok()
);
}

#[test]
fn_value_with_unsatisfied_lifetime_bound() {
alityTest::new(crates![crate Foo {
fn require<'a, 'b>() -> () where 'a: 'b {}
fn outer<'a, 'b>() -> () { require::<'a, 'b>; }
fn main() -> () {}
}])
tc_err(expect_test::expect![[r#"
error: lifetime may not live long enough
 --> lib.rs
  |
7 | pub fn outer<'a00, 'a01>() -> () {
  |              ----  ---- lifetime `'a01` defined here
  |              |
  |              lifetime `'a00` defined here
8 |     require::<'a00, 'a01>;
  |     ^^^^^^^^^^^^^^^^^^^^^ requires that `'a00` must outlive `'a01`
  |
  = help: consider adding the following bound: `'a00: 'a01`

error: could not compile `Foo` (lib) due to 1 previous error
)
(expect_test::expect!["crates/formality-rust/src/prove/prove_outlives.rs:8:1: no applicable rules for prove_outlives { a: !lt_0, b: !lt_1, assumptions: {}, env: Env { variables: [!lt_0, !lt_1], bias: Soundness, pending: [], allow_pending_outlives: false } }"]);
}

ound assignment of an integer of a different type should fail.
#[test]
compound_add_mismatched_int_types() {
alityTest::new(crates![crate Foo {
fn foo() -> () {
    let x: u32 = 1_u32;
    x += 2_u8;
}

How to read this page