blob: cbf8279918a2178e40e491c909d751b775bf980e (
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
43
44
45
46
47
48
49
50
51
52
53
|
#![feature(coverage_attribute)]
//@ edition: 2024
//@ revisions: base auto on
// Tests for how `#[automatically_derived]` affects coverage instrumentation.
//
// The actual behaviour is an implementation detail, so this test mostly exists
// to show when that behaviour has been accidentally or deliberately changed.
//
// Revision guide:
// - base: Test baseline instrumentation behaviour without `#[automatically_derived]`
// - auto: Test how `#[automatically_derived]` affects instrumentation
// - on: Test interaction between auto-derived and `#[coverage(on)]`
struct MyStruct;
trait MyTrait {
fn my_assoc_fn();
}
#[cfg_attr(auto, automatically_derived)]
#[cfg_attr(on, automatically_derived)]
#[cfg_attr(on, coverage(on))]
impl MyTrait for MyStruct {
fn my_assoc_fn() {
fn inner_fn() {
say("in inner fn");
}
#[coverage(on)]
fn inner_fn_on() {
say("in inner fn (on)");
}
let closure = || {
say("in closure");
};
closure();
inner_fn();
inner_fn_on();
}
}
#[coverage(off)]
#[inline(never)]
fn say(s: &str) {
println!("{s}");
}
fn main() {
MyStruct::my_assoc_fn();
}
|