Auto merge of #124507 - Zalathar:coverage-level, r=compiler-errors

coverage: Replace boolean options with a `CoverageLevel` enum

After #123409, and some discussion at https://github.com/rust-lang/rust/issues/79649#issuecomment-2042093553 and #124120, it became clear to me that we should have a unified concept of “coverage level”, instead of having several separate boolean flags that aren't actually independent.

This PR therefore introduces a `CoverageLevel` enum, to replace the existing boolean flags for `branch` and `mcdc`.

The `no-branch` value (for `-Zcoverage-options`) has been renamed to `block`, instructing the compiler to only instrument for block coverage, with no branch coverage or MD/DC instrumentation.

`@rustbot` label +A-code-coverage
cc `@ZhuUx` `@Lambdaris` `@RenjiSann`
This commit is contained in:
bors 2024-04-30 02:47:25 +00:00
commit f9dca46218
8 changed files with 53 additions and 39 deletions

View file

@ -1,2 +1,2 @@
error: incorrect value `bad` for unstable option `coverage-options` - either `no-branch`, `branch` or `mcdc` was expected
error: incorrect value `bad` for unstable option `coverage-options` - `block` | `branch` | `mcdc` was expected

View file

@ -1,20 +1,17 @@
//@ needs-profiler-support
//@ revisions: branch no-branch bad
//@ revisions: block branch bad
//@ compile-flags -Cinstrument-coverage
//@ [block] check-pass
//@ [block] compile-flags: -Zcoverage-options=block
//@ [branch] check-pass
//@ [branch] compile-flags: -Zcoverage-options=branch
//@ [no-branch] check-pass
//@ [no-branch] compile-flags: -Zcoverage-options=no-branch
//@ [mcdc] check-pass
//@ [mcdc] compile-flags: -Zcoverage-options=mcdc
//@ [bad] check-fail
//@ [bad] compile-flags: -Zcoverage-options=bad
//@ [conflict] check-fail
//@ [conflict] compile-flags: -Zcoverage-options=no-branch,mcdc
fn main() {}