-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Vastly improves coverage spans for macros #84582
Conversation
This comment has been minimized.
This comment has been minimized.
b76f133
to
2d72f54
Compare
This comment has been minimized.
This comment has been minimized.
Also fixes #82853, I believe. |
@tmandry I moved the spanview debug output ICE fix to this PR instead of the Thanks! |
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.inner_items.txt
Show resolved
Hide resolved
@tmandry - Great review comments. I resolved the simple requests. Check out my replies (and changes, where relevant). Thanks! |
(To be a little more clear, I addressed all of your comments. I just marked the simple ones resolved, to reduce the clutter on this page.) |
Looks good, thanks for making those changes! @bors r+ |
📌 Commit fd85fd3 has been approved by |
Vastly improves coverage spans for macros Fixes: rust-lang#84561 This resolves problems where macros like `trace!(...)` would show zero coverage if tracing was disabled, and `assert_eq!(...)` would show zero coverage if the assertion did not fail, because only one coverage span was generated, for the branch. This PR started with an idea that I could just drop branching blocks with same span as expanded macro. (See the fixed issue for more details.) That did help, but it didn't resolve everything. I also needed to add a span specifically for the macro name (plus `!`) to ensure the macro gets coverage even if it's internal expansion adds conditional branching blocks that are retained, and would otherwise drop the outer span. Now that outer span is _only_ the `(argument, list)`, which can safely be dropped now), because the macro name has its own span. While testing, I also noticed the spanview debug output can cause an ICE on a function with no body. The workaround for this is included in this PR (separate commit). r? `@tmandry` cc? `@wesleywiser`
Vastly improves coverage spans for macros Fixes: rust-lang#84561 This resolves problems where macros like `trace!(...)` would show zero coverage if tracing was disabled, and `assert_eq!(...)` would show zero coverage if the assertion did not fail, because only one coverage span was generated, for the branch. This PR started with an idea that I could just drop branching blocks with same span as expanded macro. (See the fixed issue for more details.) That did help, but it didn't resolve everything. I also needed to add a span specifically for the macro name (plus `!`) to ensure the macro gets coverage even if it's internal expansion adds conditional branching blocks that are retained, and would otherwise drop the outer span. Now that outer span is _only_ the `(argument, list)`, which can safely be dropped now), because the macro name has its own span. While testing, I also noticed the spanview debug output can cause an ICE on a function with no body. The workaround for this is included in this PR (separate commit). r? ``@tmandry`` cc? ``@wesleywiser``
Vastly improves coverage spans for macros Fixes: rust-lang#84561 This resolves problems where macros like `trace!(...)` would show zero coverage if tracing was disabled, and `assert_eq!(...)` would show zero coverage if the assertion did not fail, because only one coverage span was generated, for the branch. This PR started with an idea that I could just drop branching blocks with same span as expanded macro. (See the fixed issue for more details.) That did help, but it didn't resolve everything. I also needed to add a span specifically for the macro name (plus `!`) to ensure the macro gets coverage even if it's internal expansion adds conditional branching blocks that are retained, and would otherwise drop the outer span. Now that outer span is _only_ the `(argument, list)`, which can safely be dropped now), because the macro name has its own span. While testing, I also noticed the spanview debug output can cause an ICE on a function with no body. The workaround for this is included in this PR (separate commit). r? ````@tmandry```` cc? ````@wesleywiser````
Vastly improves coverage spans for macros Fixes: rust-lang#84561 This resolves problems where macros like `trace!(...)` would show zero coverage if tracing was disabled, and `assert_eq!(...)` would show zero coverage if the assertion did not fail, because only one coverage span was generated, for the branch. This PR started with an idea that I could just drop branching blocks with same span as expanded macro. (See the fixed issue for more details.) That did help, but it didn't resolve everything. I also needed to add a span specifically for the macro name (plus `!`) to ensure the macro gets coverage even if it's internal expansion adds conditional branching blocks that are retained, and would otherwise drop the outer span. Now that outer span is _only_ the `(argument, list)`, which can safely be dropped now), because the macro name has its own span. While testing, I also noticed the spanview debug output can cause an ICE on a function with no body. The workaround for this is included in this PR (separate commit). r? `````@tmandry````` cc? `````@wesleywiser`````
Possibly failed in #84720 (comment) @bors rollup=iffy |
Oh, darn. This test output changed after the new The But this PR was uploaded before the Will fix.
|
@bors r- I may have found one more edge case, plus I'm not sure if I need to re-bless one other test result. |
self.prev_mut().span = self.prev().span.with_lo(right_cutoff); | ||
self.prev_original_span = self.prev().span; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line updating prev_original_span
to match the mutated self.prev().span
has been wrong for a long time. It's clear, now, that the original_span should never be mutated, and this was always a bug.
I think recent changes elsewhere may have exposed this bug, but even so, it still occurs very rarely.
I added some tests to try to replicate the failures I saw when compiling a very large codebase, but it's very hard to replicate. (It seems to occur when calling a macro that contains a closure and returns a Result, checked with the ?
try operator. But even that is not enough to replicate the problem. It also requires that the macro code branches, and that it produces just the right order of dominator relationship between basic blocks, with just the right nested but equal spans.
The bug is clear to me even if the specific situation leading up to that bug is not as clear. I validated this against the code that triggered the error (at least 3 instances) and removing this line corrected the problem, allowing the codebase to compile to completion.
r? @tmandry - can you take a quick look and re-approve / re-submit to bors? |
@rustbot label -S-waiting-on-author +S-waiting-on-review |
@bors r+ |
📌 Commit 0312bf5 has been approved by |
☀️ Test successful - checks-actions |
Fixes: #84561
This resolves problems where macros like
trace!(...)
would show zero coverage if tracing was disabled, andassert_eq!(...)
would show zero coverage if the assertion did not fail, because only one coverage span was generated, for the branch.This PR started with an idea that I could just drop branching blocks with same span as expanded macro. (See the fixed issue for more details.)
That did help, but it didn't resolve everything.
I also needed to add a span specifically for the macro name (plus
!
) to ensure the macro gets coverage even if it's internal expansion adds conditional branching blocks that are retained, and would otherwise drop the outer span. Now that outer span is only the(argument, list)
, which can safely be dropped now), because the macro name has its own span.While testing, I also noticed the spanview debug output can cause an ICE on a function with no body. The
workaround for this is included in this PR (separate commit).
r? @tmandry
cc? @wesleywiser