rust-lang / rust-lang/rust

Rust Coverage not working if macros are formatted across multiple lines

Open
#142,291 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-code-coverage C-bug S-needs-repro T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

    log::info!(
        "hello world {} 12323123123123123123123123123123123123123123123123",
        "Testing"
    );

I expected all lines to be covered. However, only the first line

log::info!(

All other lines are not covered

rustc --version --verbose:

rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report with the multiline log::info! example and the supplied rustc --version --verbose details. Trace how coverage maps macro-expanded source spans to lines, then verify that every line in the example is reported as covered. Done means multiline macro formatting no longer leaves the argument lines uncovered.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.