Skip to content

#[doc(hidden)] causes type's traits to disappear from rustdoc JSON built with --document-hidden-items #107278

Closed
@obi1kenobi

Description

@obi1kenobi

Affected crate: toml_edit, at path crates/toml_edit in repo https://github.com/toml-rs/toml
Commit: d86370fc5e8777e532de457cb6569feeae6429f0
Building rustdoc JSON with RUSTDOCFLAGS="-Z unstable-options --document-private-items --document-hidden-items --output-format=json"

Consider the following type from crates/toml_edit/src/easy/value.rs in that commit:

#[doc(hidden)]
#[deprecated(since = "0.18.0", note = "Replaced with `toml::Value`")]
#[derive(PartialEq, Clone, Debug, serde::Serialize)]
#[serde(untagged)]
pub enum Value {
    // < omitted >
}

I expected to see this happen: the rustdoc JSON should state that PartialEq, Clone, Debug, Send, Sync, Unpin etc. are all implemented for that type.

Instead, this happened: none of those traits are listed as implemented for that type.

Deleting #[doc(hidden)] and rebuilding the rustdoc JSON causes all the missing trait impls to be present again.

Meta

rustc --version --verbose:

rustc 1.66.1 (90743e729 2023-01-10)
binary: rustc
commit-hash: 90743e7298aca107ddaa0c202a4d3604e29bfeb6
commit-date: 2023-01-10
host: x86_64-unknown-linux-gnu
release: 1.66.1
LLVM version: 15.0.2

The same bug is present on nightly:

rustc 1.69.0-nightly (c8e6a9e8b 2023-01-23)
binary: rustc
commit-hash: c8e6a9e8b6251bbc8276cb78cabe1998deecbed7
commit-date: 2023-01-23
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

The bug was first spotted by @epage who filed a bug report on cargo-semver-checks for incorrectly reporting that types stopped being Send / Sync / Debug / Clone etc. Of course we now know this was because those traits were genuinely not present in the underlying rustdoc JSON file.

Thanks for all the awesome work you've been doing! It's been absolutely fundamental for cargo-semver-checks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-jsonArea: Rustdoc JSON backendC-bugCategory: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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