Skip to content

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

Closed
@obi1kenobi

Description

@obi1kenobi
Member

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.

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Jan 27, 2023
GuillaumeGomez

GuillaumeGomez commented on Jan 27, 2023

@GuillaumeGomez
Member

It should be fixed with #107000.

added
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Feb 3, 2023
aDotInTheVoid

aDotInTheVoid commented on Feb 3, 2023

@aDotInTheVoid
Member

That didn't fix it

MCVE:

// compile-flags: --document-private-items --document-hidden-items
#![feature(no_core)]
#![no_core]

pub trait TheTrait {}

#[doc(hidden)]
struct Value {}

impl TheTrait for Value {}

Produces (On f63ccaf)

    "0:1:1585": {
      "crate_id": 0,
      "docs": null,
      "id": "0:1:1585",
      "inner": {
        "bounds": [],
        "generics": {"params": [], "where_predicates": []},
        "implementations": [],
        "is_auto": false,
        "is_unsafe": false,
        "items": []
      },
      "kind": "trait",
      "name": "TheTrait"
    },
    "0:2:1586": {
      "crate_id": 0,
      "docs": null,
      "id": "0:2:1586",
      "inner": {
        "generics": {"params": [], "where_predicates": []},
        "impls": [],
        "kind": {"plain": {"fields": [], "fields_stripped": false}}
      },
      "kind": "struct",
      "name": "Value"
    }
added
S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
and removed
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Mar 6, 2023
its-the-shrimp

its-the-shrimp commented on Aug 8, 2024

@its-the-shrimp
Contributor

This is fixed & works just fine as of today

obi1kenobi

obi1kenobi commented on Aug 8, 2024

@obi1kenobi
MemberAuthor
its-the-shrimp

its-the-shrimp commented on Aug 8, 2024

@its-the-shrimp
Contributor

Absolutely, that's what I've done in #128836

added 2 commits that reference this issue on Aug 8, 2024

Rollup merge of rust-lang#128836 - its-the-shrimp:add_test_for_107278…

f744f75

Rollup merge of rust-lang#128836 - its-the-shrimp:add_test_for_107278…

8789b95
added a commit that references this issue on Aug 9, 2024
b1a13b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Participants

      @obi1kenobi@GuillaumeGomez@aDotInTheVoid@its-the-shrimp

      Issue actions

        `#[doc(hidden)]` causes type's traits to disappear from rustdoc JSON built with `--document-hidden-items` · Issue #107278 · rust-lang/rust