]> git.lizzy.rs Git - rust.git/blob - src/doc/unstable-book/src/language-features/no-coverage.md
Rollup merge of #106904 - khuey:preserve_debuginfo_for_rlibs, r=davidtwco
[rust.git] / src / doc / unstable-book / src / language-features / no-coverage.md
1 # `no_coverage`
2
3 The tracking issue for this feature is: [#84605]
4
5 [#84605]: https://github.com/rust-lang/rust/issues/84605
6
7 ---
8
9 The `no_coverage` attribute can be used to selectively disable coverage
10 instrumentation in an annotated function. This might be useful to:
11
12 -   Avoid instrumentation overhead in a performance critical function
13 -   Avoid generating coverage for a function that is not meant to be executed,
14     but still target 100% coverage for the rest of the program.
15
16 ## Example
17
18 ```rust
19 #![feature(no_coverage)]
20
21 // `foo()` will get coverage instrumentation (by default)
22 fn foo() {
23   // ...
24 }
25
26 #[no_coverage]
27 fn bar() {
28   // ...
29 }
30 ```