Skip to content

Rustdoc --show-coverage is wrong for reexported items #110330

Open
@aDotInTheVoid

Description

@aDotInTheVoid

a/src/lib.rs

pub use b::*;

b/src/lib.rs

/// Documented with example
///
/// ```
/// // The example
/// ```
pub struct B1;
/// Documented, no example
pub struct B2;
// Undocumented
pub struct B3;

In b

b$ cargo +nightly rustdoc -- -Z unstable-options --show-coverage
 Documenting b v0.1.0 (/home/gh-aDotInTheVoid/tmp/b)
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| src/lib.rs                          |          2 |      50.0% |          1 |      25.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          2 |      50.0% |          1 |      25.0% |
+-------------------------------------+------------+------------+------------+------------+
    Finished dev [unoptimized + debuginfo] target(s) in 0.32s

But In a:

a$ cargo +nightly rustdoc -- -Z unstable-options --show-coverage
 Documenting a v0.1.0 (/home/gh-aDotInTheVoid/tmp/a)
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| src/lib.rs                          |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
    Finished dev [unoptimized + debuginfo] target(s) in 0.11s

These outputs should be the same.

When writing tests for this, also add one with --output-format json, as that flag is overloaded between this and the json backend, and the json backend interacts in funny ways with inlining.

rustdoc 1.70.0-nightly (a41fc00 2023-04-13)
binary: rustdoc
commit-hash: unknown
commit-date: unknown
host: aarch64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 16.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doc-coverageArea: Calculating how much of a crate has documentationT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions