Add E0788 for improper #[no_coverage] usage

This commit is contained in:
ltdk 2022-05-28 17:20:43 -04:00
parent ebbcbfc236
commit 5fabdb8f7f
5 changed files with 202 additions and 0 deletions

View file

@ -491,6 +491,7 @@ E0784: include_str!("./error_codes/E0784.md"),
E0785: include_str!("./error_codes/E0785.md"),
E0786: include_str!("./error_codes/E0786.md"),
E0787: include_str!("./error_codes/E0787.md"),
E0788: include_str!("./error_codes/E0788.md"),
;
// E0006, // merged with E0005
// E0008, // cannot bind by-move into a pattern guard

View file

@ -0,0 +1,21 @@
A `#[no_coverage]` attribute was incorrectly placed on something that couldn't
be covered.
Example of erroneous code:
```compile_fail,E0788
#[no_coverage]
struct Foo;
#[no_coverage]
const FOO: Foo = Foo;
```
`#[no_coverage]` tells the compiler to not generate coverage instrumentation for
a piece of code when the `-C instrument-coverage` flag is passed. Things like
structs and consts are not coverable code, and thus cannot do anything with this
attribute.
If you wish to apply this attribute to all methods in an impl or module,
manually annotate each method; it is not possible to annotate the entire impl
with a `#[no_coverage]` attribute.