Skip to content

Compiling with RUSTFLAGS="-C instrument-coverage" changes dependency tracking for doctest builds #95825

Open
@scouten-adobe

Description

@scouten-adobe

I have a (currently) closed-source crate. I'm trying to use the new coverage tools built into Rust 1.60 stable and I'm seeing some unexpected behavior when trying to run unit tests with coverage enabled.

When I run:

RUSTFLAGS="-C instrument-coverage" cargo test --all-features

I get hundreds of errors of the form …

error[E0463]: can't find crate for `serde_derive` which `ciborium` depends on
 --> (path redacted)
  |
4 | use ciborium::value::Value;
  |     ^^^^^^^^ can't find crate

… when it gets to the doctest portion of the test suite. (Ironically, this crate currently has no doc tests.)

If I add …

[lib]
doctest = false

… to Cargo.toml or compile without the instrument-coverage flag, I have no such errors.

Rust 1.60 stable, macOS 12.1 (Intel), closed-source (currently) crate.

Before I start digging in deeper, I would like to know if:

(a) Anyone else is seeing anything like this?
(b) Would it help the Rust core team if I could find a publicly-visible repro case?

Meta

rustc --version --verbose:

rustc 1.60.0 (7737e0b5c 2022-04-04)
binary: rustc
commit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c
commit-date: 2022-04-04
host: x86_64-apple-darwin
release: 1.60.0
LLVM version: 14.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)A-doctestsArea: Documentation tests, run by rustdocC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions