Skip to content

code coverage reporting for let-else interacts poorly with rustfmt #143149

Open

Description

@briansmith

I tried this code:

 let (m_original, []) = slice::as_chunks::<_, 8>(m.limbs()) else {
     return Err(LimbSliceError::len_mismatch(LenMismatchError::new(8)));
}

In my test suite, the positive if case is covered, but the else is never covered.

I expected to see this happen:

Code coverage tools should clearly report that let (m_original, []) = slice::as_chunks::<_, 8>(m.limbs()) is fully covered and should clearly report that the entire else case is not covered.

Instead, this happened:

Code coverage reports that let (m_original, []) = slice::as_chunks::<_, 8>(m.limbs()) else { is partially covered and that the rest of the else is uncovered:

Image

This is really unfortunate as it leads to confusion about whether part of the positive case is uncovered.

Meta

rustc +nightly --version --verbose:

rustc 1.90.0-nightly (706f244db 2025-06-23)
binary: rustc
commit-hash: 706f244db581212cabf2e619e0113d70999b2bbe
commit-date: 2025-06-23
host: aarch64-apple-darwin
release: 1.90.0-nightly
LLVM version: 20.1.7

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jun 28, 2025
  2. added
    F-let_elseIssues related to let-else statements (RFC 3137)
    on Jul 2, 2025
  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)C-bugCategory: This is a bug.F-let_elseIssues related to let-else statements (RFC 3137)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions