rust/tests/coverage/attr/off-on-sandwich.rs
Zalathar 63c04f05e6 coverage: Extract hole spans from HIR instead of MIR
This makes it possible to treat more kinds of nested item/code as holes,
instead of being restricted to closures.
2024-07-08 21:22:56 +10:00

53 lines
932 B
Rust

#![feature(coverage_attribute)]
//@ edition: 2021
// Demonstrates the interaction of `#[coverage(off)]` and `#[coverage(on)]`
// in nested functions.
#[coverage(off)]
fn do_stuff() {}
#[coverage(off)]
fn dense_a() {
dense_b();
dense_b();
#[coverage(on)]
fn dense_b() {
dense_c();
dense_c();
#[coverage(off)]
fn dense_c() {
do_stuff();
}
}
}
#[coverage(off)]
fn sparse_a() {
sparse_b();
sparse_b();
fn sparse_b() {
sparse_c();
sparse_c();
#[coverage(on)]
fn sparse_c() {
sparse_d();
sparse_d();
fn sparse_d() {
sparse_e();
sparse_e();
#[coverage(off)]
fn sparse_e() {
do_stuff();
}
}
}
}
}
#[coverage(off)]
fn main() {
dense_a();
sparse_a();
}