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

division
LineCoverageSource
387N/A(let expr = Expr::bin_op(lhs, BinOpKind::Div, rhs))
3882(borrow_check_expr(env, assumptions, state, expr, places_live_on_exit) => (ty, state))
──────── ("division")
39019(borrow_check_expr(env, assumptions, state, Expr::Div { lhs, rhs }, places_live_on_exit) => (ty, state))

19 tests exercised this rule:


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

fn main() -> () {
    println!(12_i32 / 3_i32);
}
Proof tree
… (200 of 1301 nodes shown)

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

fn main() -> () {
    println!(7_i32 / 2_i32);
}
Proof tree
… (200 of 1301 nodes shown)

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

fn main() -> () {
    println!(-7_i32 / 2_i32);
}
Proof tree
… (200 of 1301 nodes shown)

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

fn main() -> () {
    println!(2_i32 + 12_i32 / 3_i32);
}
Proof tree
… (200 of 1310 nodes shown)

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

fn main() -> () {
    println!(24_i32 / 4_i32 / 2_i32);
}
Proof tree
… (200 of 1311 nodes shown)

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

fn main() -> () {
    println!(24_i32 / (4_i32 / 2_i32));
}
Proof tree
… (200 of 1312 nodes shown)

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

fn main() -> () {
    println!(13_u32 / 3_u32);
    println!(0_u32 / 3_u32);
}
Proof tree
… (200 of 1314 nodes shown)

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

fn main() -> () {
    println!(7_i32 / -2_i32);
    println!(-7_i32 / -2_i32);
}
Proof tree
… (200 of 1314 nodes shown)

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

fn main() -> () {
    println!(20_i32 - 12_i32 / 3_i32);
    println!(12_i32 / 3_i32 - 2_i32);
    println!((20_i32 - 12_i32) / 2_i32);
}
Proof tree
… (200 of 1355 nodes shown)

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

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

ust reports invalid division as an execution error.
 #543: assert a defined abort instead of accepting the MiniRust UB diagnostic.
#[test]
_panic(expected = "division by zero")]
er_division_by_zero() {
alityTest::new(crates![crate Foo {
fn main() -> () {
    println!(12_i32 / 0_i32);
}
Proof tree
… (200 of 1369 nodes shown)

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

fn main() -> () {
    println!(12_i32 / 0_i32);
}

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


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

fn main() -> () {
    println!(-2147483648_i32 / -1_i32);
}

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

fn main() -> () {
    println!(24_i32 / 4_i32 * 2_i32);
    println!(20_i32 * 3_i32 / 4_i32);
    println!(24_i32 / (4_i32 * 2_i32));
    println!(2_i32 + 24_i32 / 4_i32 * 2_i32);
}

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

fn main() -> () {
    println!(2_i32 / 7_i32);
    println!(-2_i32 / 7_i32);
}

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

fn main() -> () {
    println!(127_i8 / 2_i8);
    println!(-127_i8 / 2_i8);
    println!(18446744073709551616_u128 / 2_u128);
}

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

fn main() -> () {
    let x: i32 = 0_i32;
    x = 12_i32 / 3_i32;
    println!(x);
}

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

fn main() -> () {
    println!(sum(12_i32 / 3_i32, 10_i32 / 2_i32));
}

Source location: tests/division_abort.rs:40 (all coverage from this test)

#[test]
#[should_panic(expected = "expected a defined abort, got Ub(String(\"division by zero\"))")]
fn division_by_zero_aborts() {
    assert_aborts(crates![crate Foo {
        fn divide(lhs: u32, rhs: u32) -> u32 { return lhs / rhs; }
        fn main() -> () { println!(divide(12_u32, 0_u32)); }
    }]);
}

Source location: tests/division_abort.rs:50 (all coverage from this test)

#[test]
#[should_panic(expected = "expected a defined abort, got Ub(String(\"overflow in division\"))")]
fn signed_division_overflow_aborts() {
    assert_aborts(crates![crate Foo {
        fn divide(lhs: i32, rhs: i32) -> i32 { return lhs / rhs; }
        fn main() -> () { println!(divide(-2147483648_i32, -1_i32)); }
    }]);
}

How to read this page