Skip to content

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

Closed
qaijuang wants to merge 0 commit into
rust-lang:mainfrom
qaijuang:async_closure_coverage
Closed

coverage: Use original HIR info for synthetic by-move coroutine bodies#156952
qaijuang wants to merge 0 commit into
rust-lang:mainfrom
qaijuang:async_closure_coverage

Conversation

@qaijuang
Copy link
Copy Markdown
Contributor

@qaijuang qaijuang commented May 26, 2026

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.

@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
@qaijuang qaijuang marked this pull request as ready for review May 26, 2026 08:28
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 26, 2026

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in coverage tests.

cc @Zalathar

Some changes occurred in coverage instrumentation.

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
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 26, 2026

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 18 candidates

Comment thread compiler/rustc_mir_transform/src/coverage/hir_info.rs Outdated
Comment thread compiler/rustc_mir_transform/src/coverage/hir_info.rs Outdated
@qaijuang qaijuang force-pushed the async_closure_coverage branch 2 times, most recently from 9c2205f to 8d5446a Compare May 26, 2026 13:42
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 26, 2026
@qaijuang qaijuang closed this May 26, 2026
@qaijuang qaijuang force-pushed the async_closure_coverage branch from 8d5446a to b7e97a9 Compare May 26, 2026 13:45
@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 26, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot rustbot removed the has-merge-commits PR has merge commits, merge with caution. label May 26, 2026
@qaijuang qaijuang deleted the async_closure_coverage branch May 26, 2026 13:48
@qaijuang
Copy link
Copy Markdown
Contributor Author

my git is acting weird, i'll reopen this as a new PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

4 participants