-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Coverage instrumentation sometimes thinks the negation operator isn't executable #115468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
(This issue is based on my original notes at #111752 (comment).) |
This seems to be the result of When that happens, the For now, it’s probably not worth trying to add another special case, since the difference is hardly noticeable most of the time. It might be worth revisiting this if we ever implement deeper coverage integration into HIR-to-MIR lowering. |
@rustbot label -needs-triage |
@rustbot label +T-compiler |
As I continue to investigate branch coverage, this has become more of a concern. When the user writes |
coverage: Use `SpanMarker` to improve coverage spans for `if !` expressions Coverage instrumentation works by extracting source code spans from MIR. However, some kinds of syntax are effectively erased during MIR building, so their spans don't necessarily exist anywhere in MIR, making them invisible to the coverage instrumentor (unless we resort to various heuristics and hacks to recover them). This PR introduces `CoverageKind::SpanMarker`, which is a new variant of `StatementKind::Coverage`. Its sole purpose is to represent spans that would otherwise not appear in MIR, so that the coverage instrumentor can extract them. When coverage is enabled, the MIR builder can insert these dummy statements as needed, to improve the accuracy of spans used by coverage mappings. Fixes rust-lang#115468. --- `@rustbot` label +A-code-coverage
coverage: Use `SpanMarker` to improve coverage spans for `if !` expressions Coverage instrumentation works by extracting source code spans from MIR. However, some kinds of syntax are effectively erased during MIR building, so their spans don't necessarily exist anywhere in MIR, making them invisible to the coverage instrumentor (unless we resort to various heuristics and hacks to recover them). This PR introduces `CoverageKind::SpanMarker`, which is a new variant of `StatementKind::Coverage`. Its sole purpose is to represent spans that would otherwise not appear in MIR, so that the coverage instrumentor can extract them. When coverage is enabled, the MIR builder can insert these dummy statements as needed, to improve the accuracy of spans used by coverage mappings. Fixes rust-lang#115468. --- ``@rustbot`` label +A-code-coverage
coverage: Use `SpanMarker` to improve coverage spans for `if !` expressions Coverage instrumentation works by extracting source code spans from MIR. However, some kinds of syntax are effectively erased during MIR building, so their spans don't necessarily exist anywhere in MIR, making them invisible to the coverage instrumentor (unless we resort to various heuristics and hacks to recover them). This PR introduces `CoverageKind::SpanMarker`, which is a new variant of `StatementKind::Coverage`. Its sole purpose is to represent spans that would otherwise not appear in MIR, so that the coverage instrumentor can extract them. When coverage is enabled, the MIR builder can insert these dummy statements as needed, to improve the accuracy of spans used by coverage mappings. Fixes rust-lang#115468. --- ```@rustbot``` label +A-code-coverage
Rollup merge of rust-lang#118198 - Zalathar:if-not, r=cjgillot coverage: Use `SpanMarker` to improve coverage spans for `if !` expressions Coverage instrumentation works by extracting source code spans from MIR. However, some kinds of syntax are effectively erased during MIR building, so their spans don't necessarily exist anywhere in MIR, making them invisible to the coverage instrumentor (unless we resort to various heuristics and hacks to recover them). This PR introduces `CoverageKind::SpanMarker`, which is a new variant of `StatementKind::Coverage`. Its sole purpose is to represent spans that would otherwise not appear in MIR, so that the coverage instrumentor can extract them. When coverage is enabled, the MIR builder can insert these dummy statements as needed, to improve the accuracy of spans used by coverage mappings. Fixes rust-lang#115468. --- ```@rustbot``` label +A-code-coverage
#111752 introduced this behaviour in coverage reports:
Notice that the line with
!
no longer has a coverage count, even though it should have the same count asis_true
.This is caused by the fact that MIR building specifically handles
if !
by flipping the then/else arms, so the original condition expression (containing!
) does not have its span represented by any statement in MIR.The text was updated successfully, but these errors were encountered: