Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
obi1kenobi opened this issue Jan 24, 2023 · 5 comments · Fixed by #128836
Labels
A-rustdoc-json Area: Rustdoc JSON backend C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@obi1kenobi
Copy link
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.

@obi1kenobi obi1kenobi added the C-bug Category: This is a bug. label Jan 24, 2023
@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-json Area: Rustdoc JSON backend labels Jan 27, 2023
@GuillaumeGomez
Copy link
Member

It should be fixed with #107000.

@aDotInTheVoid aDotInTheVoid added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Feb 3, 2023
@aDotInTheVoid
Copy link
Member

aDotInTheVoid commented Feb 3, 2023

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"
    }

@aDotInTheVoid aDotInTheVoid added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Mar 6, 2023
@its-the-shrimp
Copy link
Contributor

This is fixed & works just fine as of today

@obi1kenobi
Copy link
Member Author

obi1kenobi commented Aug 8, 2024 via email

@its-the-shrimp
Copy link
Contributor

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

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 8, 2024
…, r=aDotInTheVoid

rustdoc-json: add a test for impls on private & hidden types

Fixes rust-lang#107278 (or rather just ensures it won't resurface)
r? `@aDotInTheVoid`
@bors bors closed this as completed in 8789b95 Aug 9, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 9, 2024
Rollup merge of rust-lang#128836 - its-the-shrimp:add_test_for_107278, r=aDotInTheVoid

rustdoc-json: add a test for impls on private & hidden types

Fixes rust-lang#107278 (or rather just ensures it won't resurface)
r? ``@aDotInTheVoid``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants