]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0788.md
Changes from code review
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0788.md
1 A `#[no_coverage]` attribute was applied to something which does not show up
2 in code coverage, or is too granular to be excluded from the coverage report.
3
4 For now, this attribute can only be applied to function, method, and closure
5 definitions. In the future, it may be added to statements, blocks, and
6 expressions, and for the time being, using this attribute in those places
7 will just emit an `unused_attributes` lint instead of this error.
8
9 Example of erroneous code:
10
11 ```compile_fail,E0788
12 #[no_coverage]
13 struct Foo;
14
15 #[no_coverage]
16 const FOO: Foo = Foo;
17 ```
18
19 `#[no_coverage]` tells the compiler to not generate coverage instrumentation for
20 a piece of code when the `-C instrument-coverage` flag is passed. Things like
21 structs and consts are not coverable code, and thus cannot do anything with this
22 attribute.
23
24 If you wish to apply this attribute to all methods in an impl or module,
25 manually annotate each method; it is not possible to annotate the entire impl
26 with a `#[no_coverage]` attribute.