Skip to content

rustdoc --show-coverage misses associated items on public items re-exported from private modules #129007

Open
@Nemo157

Description

@Nemo157

I tried this code:

// src/lib.rs
//! ```
//! ```

pub mod foo;
pub mod bar;
// src/foo.rs
//! ```
//! ```

/// ```
/// ```
pub struct Foo;

impl Foo {
    /// ```
    /// ```
    pub fn foo() {}
}
// src/bar.rs
//! ```
//! ```

mod inner {
    /// ```
    /// ```
    pub struct Bar;

    impl Bar {
        pub fn bar() {}
    }
}

pub use inner::Bar;
> cargo rustdoc -- --show-coverage -Zunstable-options

I expected to see this happen:

+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| src/bar.rs                          |          2 |      66.7% |          2 |      66.7% |
| src/foo.rs                          |          3 |     100.0% |          3 |     100.0% |
| src/lib.rs                          |          1 |     100.0% |          1 |     100.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          6 |     100.0% |          6 |     100.0% |
+-------------------------------------+------------+------------+------------+------------+

Instead, this happened:

+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| src/bar.rs                          |          2 |     100.0% |          2 |     100.0% |
| src/foo.rs                          |          3 |     100.0% |          3 |     100.0% |
| src/lib.rs                          |          1 |     100.0% |          1 |     100.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          6 |     100.0% |          6 |     100.0% |
+-------------------------------------+------------+------------+------------+------------+

src/bar.rs is ignoring the undocumented public method.

The same also happens with non-inline modules.

Meta

rustdoc 1.82.0-nightly (64ebd39da 2024-08-03)
binary: rustdoc
commit-hash: 64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b
commit-date: 2024-08-03
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doc-coverageArea: Calculating how much of a crate has documentationC-bugCategory: This is a bug.T-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