Skip to content
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

Dont ICE when computing coverage of synthetic async closure body #131802

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Oct 16, 2024

I'm not totally certain if this is right, but at least it doesn't ICE.

The issue is that we end up generating two MIR bodies for each async closure, since the FnOnce and Fn/FnMut implementations have different borrowing behavior of their captured variables. They should ideally both contribute to the coverage, since those MIR bodies are (to the user) the same code and should have no behavioral differences.

This PR at least suppresses the ICEs, and then I guess worst case we can fix this the right way later.

r? Zalathar or re-roll

Fixes #131190

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 16, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 16, 2024

Some changes occurred in coverage tests.

cc @Zalathar

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in coverage instrumentation.

cc @Zalathar

@@ -0,0 +1,16 @@
#![feature(coverage_attribute)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: #![feature(coverage_attribute)] isn't needed here, as there are no #[coverage(..)] attributes in the source.

@Zalathar
Copy link
Contributor

Thanks. I don't know much about async closures (or feedable queries), but this looks like a reasonable workaround.

Other than the nit, there's one thing missing: The new test needs to be blessed again with build.profiler = true in config.toml, as there's another snapshot file (.coverage) that can only be generated/checked when the profiler runtime is available.

r=me when that's done.

@Zalathar Zalathar added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Oct 17, 2024
@Zalathar
Copy link
Contributor

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2024
@Zalathar
Copy link
Contributor

Applied review feedback (diff).

@bors r+

@bors
Copy link
Contributor

bors commented Oct 18, 2024

📌 Commit cdbf28a has been approved by Zalathar

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 18, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 18, 2024
Rollup of 9 pull requests

Successful merges:

 - rust-lang#130136 (Partially stabilize const_pin)
 - rust-lang#131755 (Regression test for AVR `rjmp` offset)
 - rust-lang#131774 (Add getentropy for RTEMS)
 - rust-lang#131802 (Dont ICE when computing coverage of synthetic async closure body)
 - rust-lang#131809 (Fix predicate signatures in retain_mut docs)
 - rust-lang#131858 (Remove outdated documentation for `repeat_n`)
 - rust-lang#131866 (Avoid use imports in `thread_local_inner!`)
 - rust-lang#131874 (Default to the medium code model on OpenHarmony LoongArch target)
 - rust-lang#131877 (checktools.sh: add link to issue for more context about disabled Miri tests)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit aae4730 into rust-lang:master Oct 18, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 18, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 18, 2024
Rollup merge of rust-lang#131802 - compiler-errors:fnonce-coverage, r=Zalathar

Dont ICE when computing coverage of synthetic async closure body

I'm not totally certain if this is *right*, but at least it doesn't ICE.

The issue is that we end up generating two MIR bodies for each async closure, since the `FnOnce` and `Fn`/`FnMut` implementations have different borrowing behavior of their captured variables. They should ideally both contribute to the coverage, since those MIR bodies are (*to the user*) the same code and should have no behavioral differences.

This PR at least suppresses the ICEs, and then I guess worst case we can fix this the right way later.

r? Zalathar or re-roll

Fixes rust-lang#131190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: index out of bounds, instrument coverage
5 participants