You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/attributes/coverage-instrumentation.md
+19-4
Original file line number
Diff line number
Diff line change
@@ -11,10 +11,10 @@ The following [attributes] are used for controlling coverage instrumentation.
11
11
r[attributes.coverage]
12
12
13
13
r[attributes.coverage.intro]
14
-
The *`coverage`[attribute]* indicates whether a function should instrument code coverage at all and show up in code coverage reports.
14
+
The *`coverage`[attribute]* indicates whether a function should include instrumentation for code coverage and show up in code coverage reports.
15
15
16
16
r[attributes.coverage.syntax]
17
-
There are two ways to use the coverage attribute:
17
+
The attribute uses the [_MetaListIdents_] syntax to specify its behavior:
18
18
19
19
*`#[coverage(off)]` indicates that all functions within an item, recursively, should not be instrumented, unless specified by another attribute.
20
20
*`#[coverage(on)]` (the default) indicates that all functions within an item, recursively, *should* be instrumented, unless specified by another attribute.
@@ -35,10 +35,25 @@ impl S {
35
35
```
36
36
37
37
r[attributes.coverage.allowed-positions]
38
-
The `coverage` attribute can only be controlled at the function level, but it can be applied to modules, `impl` blocks, or anything that can contain functions.
38
+
The `coverage` attribute can only be controlled at the granularity of individual functions. It can be applied to [functions], [closures], [associated functions], [implementations], [modules], or [the crate root].
39
+
40
+
It is an error to specify the attribute on a trait function without a body.
41
+
42
+
r[attributes.coverage.trait-impl-inherit]
43
+
When specified on a trait function, the attribute only applies to the default function body. Trait implementations do not inherit the setting from the trait definition.
44
+
45
+
r[attributes.coverage.duplicates]
46
+
It is an error to specify the `#[coverage]` attribute multiple times on the same item.
39
47
40
48
r[attributes.coverage.nesting]
41
-
More-specific attributes always take priority over less-specific ones, e.g. if a crate is marked `#![coverage(off)]`, then functions inside that crate marked `#[coverage(on)]` will still have coverage.
49
+
Coverage attributes on more deeply nested items take priority over attributes at a higher nesting level. For example, if a crate is marked `#![coverage(off)]`, then functions inside that crate marked `#[coverage(on)]` will still have coverage.
0 commit comments