Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage (-Zinstrument-coverage) showing #[derive(Eq)] as a missed region, even though Eq has no functions #83601

Closed
ThePuzzlemaker opened this issue Mar 28, 2021 · 0 comments · Fixed by #84562
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-bug Category: This is a bug.

Comments

@ThePuzzlemaker
Copy link
Contributor

I tried this code:

#[derive(Debug, PartialEq, Eq)]
struct Foo(u32);

fn main() {
    assert_eq!(Foo(1), Foo(1));
    assert_ne!(Foo(0), Foo(1));
    println!("{:?}", Foo(1));
}

Running these commands to get the code coverage report:

$ env RUSTFLAGS="-Zinstrument-coverage" CARGO_INCREMENTAL=0 cargo run
$ cargo profdata -- merge default.profraw -o default.profdata
$ cargo cov -- show --use-color --instr-profile=calypso.profdata --object target/debug/codecov-testing --show-instantiations --show-line-counts-or-regions --Xdemangler=rustfilt

This provides this report:

    1|      4|#[derive(Debug, PartialEq, Eq)]
                       ^2                ^0
  ------------------
  | <codecov_testing::Foo as core::cmp::PartialEq>::eq:
  |    1|      4|#[derive(Debug, PartialEq, Eq)]
  ------------------

I expected to see this happen: Eq is not marked as a missed region

Instead, this happened: Eq is marked as a missed region (the ^0). I'm guessing this is because of the internal assert_receiver_is_total_eq function on Eq.

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Backtrace not applicable.

@ThePuzzlemaker ThePuzzlemaker added the C-bug Category: This is a bug. label Mar 28, 2021
@jonas-schievink jonas-schievink added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Mar 28, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 28, 2021
Adds feature-gated `#[no_coverage]` function attribute, to fix derived Eq `0` coverage issue rust-lang#83601

Derived Eq no longer shows uncovered

The Eq trait has a special hidden function. MIR `InstrumentCoverage`
would add this function to the coverage map, but it is never called, so
the `Eq` trait would always appear uncovered.

Fixes: rust-lang#83601

The fix required creating a new function attribute `no_coverage` to mark
functions that should be ignored by `InstrumentCoverage` and the
coverage `mapgen` (during codegen).

Adding a `no_coverage` feature gate with tracking issue rust-lang#84605.

r? `@tmandry`
cc: `@wesleywiser`
@bors bors closed this as completed in 888d0b4 Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-bug Category: This is a bug.
Projects
None yet
2 participants