Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obk

Rework `no_coverage` to `coverage(off)`

As discussed at the tail of https://github.com/rust-lang/rust/issues/84605 this replaces the `no_coverage` attribute with a `coverage` attribute that takes sub-parameters (currently `off` and `on`) to control the coverage instrumentation.

Allows future-proofing for things like `coverage(off, reason="Tested live", issue="#12345")` or similar.
This commit is contained in:
bors 2023-09-14 01:05:18 +00:00
commit c728bf3963
38 changed files with 253 additions and 213 deletions

View file

@ -1,4 +1,4 @@
A `#[no_coverage]` attribute was applied to something which does not show up
A `#[coverage]` attribute was applied to something which does not show up
in code coverage, or is too granular to be excluded from the coverage report.
For now, this attribute can only be applied to function, method, and closure
@ -9,18 +9,18 @@ will just emit an `unused_attributes` lint instead of this error.
Example of erroneous code:
```compile_fail,E0788
#[no_coverage]
#[coverage(off)]
struct Foo;
#[no_coverage]
#[coverage(on)]
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.
`#[coverage(off)]` 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.
with a `#[coverage]` attribute.