Skip to content

rustdoc: --show-coverage shouldn't count tuple struct fields #83255

Closed
@taylordotfish

Description

@taylordotfish

rustdoc's --show-coverage flag counts public fields of tuple structs, but this doesn't really make sense, since doc attributes on such fields never appear in the generated documentation.

For example, given the following in src/lib.rs:

//! test

/// test
pub struct Test(pub u8);

cargo rustdoc -- -Z unstable-options --show-coverage reports:

+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| src/lib.rs                          |          2 |      66.7% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          2 |      66.7% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+

If src/lib.rs is changed to:

//! test

/// test
pub struct Test(
    /// test
    pub u8,
);

then the coverage is reported as 100%, but, as expected, the documentation for the pub u8 field isn't included in the documentation generated by cargo doc.

Meta

rustc 1.52.0-nightly (f5d8117c3 2021-03-16)
binary: rustc
commit-hash: f5d8117c338a788bd24abec733fd143dfceb25a0
commit-date: 2021-03-16
host: powerpc64le-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.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