Skip to content

coverage: Use original HIR info for synthetic by-move coroutine bodies#156970

Open
qaijuang wants to merge 2 commits into
rust-lang:mainfrom
qaijuang:async_closure_coverage
Open

coverage: Use original HIR info for synthetic by-move coroutine bodies#156970
qaijuang wants to merge 2 commits into
rust-lang:mainfrom
qaijuang:async_closure_coverage

Conversation

@qaijuang
Copy link
Copy Markdown
Contributor

@qaijuang qaijuang commented May 26, 2026

This is a copy of #156952(because my git was acting weird)

Synthetic by-move coroutine bodies created for async closures don't have useful HIR of their own. Coverage was falling back to the parent async closure for HIR info, which means the executed AsyncFnOnce body could inherit hole spans from the wrong body and report the user-written closure body as uncovered.

This PR uses the synthetic body's coroutine type to recover the original coroutine body def-id, then extracts HIR info from that body instead. That keeps the coverage spans tied to the body the synthetic MIR was cloned from.

Fixes #151135.

r? Zalathar

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 26, 2026

Zalathar is not on the review rotation at the moment.
They may take a while to respond.

@qaijuang qaijuang marked this pull request as ready for review May 26, 2026 14:12
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 26, 2026

Some changes occurred in coverage instrumentation.

cc @Zalathar

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in coverage tests.

cc @Zalathar

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

async closures are incorrectly marked as not covered

3 participants