Coverage spans should not overlap nested items #126626
Labels
A-code-coverage
Area: Source-based code coverage (-Cinstrument-coverage)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Currently we have special-case code that detects closure expressions within a function, and truncates any coverage spans from the outer function that would overlap with the closure. This is needed to have execution counts from the outer function show up on lines associated with the closure, which would be confusion.
However, we don't have similar handling for other kinds of nested items, such as nested functions, nested data types, and nested macros.
This can result in confusing/silly execution counts for lines associated with the inner items, as seen in this contrived example:
Notice that the lines associated with
dense_c
have an execution count of 2, even though this function is not instrumented for coverage, and the execution count of those lines is not actually 2.@rustbot label +A-code-coverage
The text was updated successfully, but these errors were encountered: