summary refs log tree commit diff
path: root/tests/coverage/coverage_attr_closure.rs
blob: 4341a868ab8466f3781f80b46a575cd80fc0212c (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
34
35
36
37
38
39
40
41
42
#![feature(coverage_attribute, stmt_expr_attributes)]
#![allow(dead_code)]
//@ edition: 2021

static GLOBAL_CLOSURE_ON: fn(&str) = #[coverage(on)]
|input: &str| {
    println!("{input}");
};
static GLOBAL_CLOSURE_OFF: fn(&str) = #[coverage(off)]
|input: &str| {
    println!("{input}");
};

#[coverage(on)]
fn contains_closures_on() {
    let _local_closure_on = #[coverage(on)]
    |input: &str| {
        println!("{input}");
    };
    let _local_closure_off = #[coverage(off)]
    |input: &str| {
        println!("{input}");
    };
}

#[coverage(off)]
fn contains_closures_off() {
    let _local_closure_on = #[coverage(on)]
    |input: &str| {
        println!("{input}");
    };
    let _local_closure_off = #[coverage(off)]
    |input: &str| {
        println!("{input}");
    };
}

#[coverage(off)]
fn main() {
    contains_closures_on();
    contains_closures_off();
}