about summary refs log tree commit diff
path: root/tests/coverage/mcdc/condition-limit.rs
blob: 2ff46b11a1681336e648d907b673403a931a6a60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#![feature(coverage_attribute)]
//@ edition: 2021
//@ min-llvm-version: 18
//@ ignore-llvm-version: 19 - 99
//@ compile-flags: -Zcoverage-options=mcdc
//@ llvm-cov-flags: --show-branches=count --show-mcdc

// Check that MC/DC instrumentation can gracefully handle conditions that
// exceed LLVM's limit of 6 conditions per decision.
//
// (The limit is enforced in `compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs`.)

fn good() {
    // With only 6 conditions, perform full MC/DC instrumentation.
    let [a, b, c, d, e, f] = <[bool; 6]>::default();
    if a && b && c && d && e && f {
        core::hint::black_box("hello");
    }
}

fn bad() {
    // With 7 conditions, fall back to branch instrumentation only.
    let [a, b, c, d, e, f, g] = <[bool; 7]>::default();
    if a && b && c && d && e && f && g {
        core::hint::black_box("hello");
    }
}

#[coverage(off)]
fn main() {
    good();
    bad();
}