Skip to content

Timing report for tests has zero-second entries for doc tests #17212

Description

@hanna-kruppe

Problem

Since Rust 1.95, the timing report produced by cargo test --timings includes entries for building "lib" (doc test) units with duration 0.0 seconds, separate from the "lib" (test) unit which has always existed (and has a non-zero duration).

I'm not sure if there is some real work happening corresponding to the (doc test) units and their duration is just not recorded, or if they're completely made up. But either way, at present these zero-second units clutter the report with misleading and/or unactionable information, especially in larger workspaces.

Example:

Image

Steps

  1. cargo new --lib dummy-doctest-timings
  2. cd dummy-doctest-timings
  3. cargo test --timings
  4. Open timing report and observe the unit called dummy-doctest-timings v0.1.0 dummy_doctest_timings "lib" (doc test) with duration 0.0s

Possible Solution(s)

No response

Notes

This worked as expected (i.e., no "(doc test)" unit) up until Rust 1.94.1 and started happening since Rust 1.95.

The minimal reproduction above actually builds a (non-doc) test and has no doc tests to run. The timing report remains the same if I do any of these changes:

  • Add a doctest to the example project.
  • Set test = false for the lib target in Cargo.toml (so no unit test binary is built or run by cargo test) -- maybe the time to build the doctests is charged to the "(test)" unit?
  • Set doctest = false (without test = false) in the manifest -- i.e., the "(doc test)" unit still shows up, even though cargo test does not report running any doctests.

Finally, if I set test = false and doctest = false, then cargo test --timing fails with this message:

error: failed to render timing report

Caused by:
  no timing data found in log

Version

cargo 1.99.0-nightly (59800466c 2026-07-07)
release: 1.99.0-nightly
commit-hash: 59800466c5c41c444d264b1010b4d57e85a7117f
commit-date: 2026-07-07
host: x86_64-unknown-linux-gnu
libgit2: 1.9.4 (sys:0.21.0 vendored)
libcurl: 8.21.0-DEV (sys:0.4.90+curl-8.21.0 vendored ssl:OpenSSL/3.6.3)
ssl: OpenSSL 3.6.3 9 Jun 2026
os: Ubuntu 24.4.0 (noble) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-timingsArea: timingsC-bugCategory: bugCommand-testS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewregression-from-stable-to-stableRegression in stable that worked in a previous stable release.

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions