Skip to content

Regression in code coverage (-Zprofile) at some point after nightly-2021-11-11 #100125

Closed
@fadeevab

Description

@fadeevab

TL;DR:

Older nightly toolchain gives an expected code coverage: rustup default nightly-2021-11-11

UPDATE: Regression is reproduced below #100125 (comment)

Prerequisites

I have a GitHub workflow which generates a code coverage report with nightly toolchain +grcov, then sending it to https://coveralls.io.

export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"

rustup default nightly
cargo test --all-features
curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf -

mkdir coverage
./grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" \
                --excl-line '#\[|=> panic!|unreachable!|Io\(std::io::Error\)' \
                --excl-br-line '#\[|=> panic!|unreachable!|assert_..!' -o ./coverage/lcov.info

I expected to see 100% code coverage on a simple file, e.g. see older coverage result: https://coveralls.io/builds/43003664/source?filename=src%2Ferror.rs - error.rs has 100% code coverage.

Instead, this happened:

  1. https://coveralls.io/builds/51398291/source?filename=src%2Ferror.rs - 9% coverage.
  2. https://coveralls.io/builds/51398291/source?filename=src%2Flib.rs - coverage goes over comment lines

Version it worked on

At least nightly-2021-11-11 toolchain works:

rustup default nightly-2021-11-11

image

However, I have not narrowed down the most recent version this worked on.

Version with regression

rustc --version --verbose:

rustc 1.64.0-nightly (0f4bcadb4 2022-07-30)
binary: rustc
commit-hash: 0f4bcadb46006bc484dad85616b484f93879ca4e
commit-date: 2022-07-30
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)C-bugCategory: This is a bug.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions