about summary refs log tree commit diff
path: root/tests/coverage/async.coverage
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-08 13:24:50 +0000
committerbors <bors@rust-lang.org>2024-07-08 13:24:50 +0000
commitcfd7cf5a0e497c238dcf9947e2eeec01837beeb4 (patch)
tree776950273fb7d4fd210f508377149c477800cb66 /tests/coverage/async.coverage
parent59a4f02f836f74c4cf08f47d76c9f6069a2f8276 (diff)
parent63c04f05e60ce27311fc1b874907188616beb558 (diff)
downloadrust-cfd7cf5a0e497c238dcf9947e2eeec01837beeb4.tar.gz
rust-cfd7cf5a0e497c238dcf9947e2eeec01837beeb4.zip
Auto merge of #127199 - Zalathar:hir-holes, r=oli-obk
coverage: Extract hole spans from HIR instead of MIR

This makes it possible to treat more kinds of nested item/code as holes, instead of being restricted to closures.

(It also potentially opens up the possibility of using HIR holes to modify branch or MC/DC spans, though we currently don't actually do this.)

Thus, this new implementation treats the following as holes:
- Closures (as before, including `async` and coroutines)
- All nested items
- Inline `const` (because why not)

This gives more accurate coverage reports, because lines occupied by holes don't show the execution count from the enclosing function.

Fixes #126626.
Diffstat (limited to 'tests/coverage/async.coverage')
-rw-r--r--tests/coverage/async.coverage20
1 files changed, 5 insertions, 15 deletions
diff --git a/tests/coverage/async.coverage b/tests/coverage/async.coverage
index e943911d310..f5473829b02 100644
--- a/tests/coverage/async.coverage
+++ b/tests/coverage/async.coverage
@@ -53,25 +53,15 @@
    LL|      1|}
    LL|       |
    LL|      1|fn j(x: u8) {
-   LL|      1|    // non-async versions of `c()`, `d()`, and `f()` to make it similar to async `i()`.
+   LL|       |    // non-async versions of `c()`, `d()`, and `f()` to make it similar to async `i()`.
    LL|      1|    fn c(x: u8) -> u8 {
    LL|      1|        if x == 8 {
-   LL|      1|            1 // This line appears covered, but the 1-character expression span covering the `1`
-                          ^0
-   LL|      1|              // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because
-   LL|      1|              // `fn j()` executes the open brace for the function body, followed by the function's
-   LL|      1|              // first executable statement, `match x`. Inner function declarations are not
-   LL|      1|              // "visible" to the MIR for `j()`, so the code region counts all lines between the
-   LL|      1|              // open brace and the first statement as executed, which is, in a sense, true.
-   LL|      1|              // `llvm-cov show` overcomes this kind of situation by showing the actual counts
-   LL|      1|              // of the enclosed coverages, (that is, the `1` expression was not executed, and
-   LL|      1|              // accurately displays a `0`).
-   LL|      1|        } else {
+   LL|      0|            1
+   LL|       |        } else {
    LL|      1|            0
-   LL|      1|        }
+   LL|       |        }
    LL|      1|    }
-   LL|      1|    fn d() -> u8 { 1 } // inner function is defined in-line, but the function is not executed
-                  ^0
+   LL|      0|    fn d() -> u8 { 1 } // inner function is defined in-line, but the function is not executed
    LL|      1|    fn f() -> u8 { 1 }
    LL|      1|    match x {
    LL|      1|        y if c(x) == y + 1 => { d(); }