rust-lang / rust-lang/rust

rustdoc-json: Dangling ID when `pub use`ing item from `#[doc(hidden)]` module

Open
#117,718 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-rustdoc-json T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

With the following code:

#[doc(hidden)]
pub mod __secrets {
    pub struct Foo;
}

pub use __secrets::Foo;

It has a dangling ID:

---- [rustdoc-json] tests/rustdoc-json/reexport/pub_use_from_doc_hidden_mod.rs stdout ----

error: jsondoclint failed!
status: exit status: 1
command: "/home/gh-aDotInTheVoid/rust2/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondoclint" "/home/gh-aDotInTheVoid/rust2/build/aarch64-unknown-linux-gnu/test/rustdoc-json/reexport/pub_use_from_doc_hidden_mod/pub_use_from_doc_hidden_mod.json"
stdout: none
--- stderr -------------------------------
0:4:1750 not in index or paths, but referred to at '$.index["0:6-0:4:1750"].inner.import.id'
Error: Errors validating json /home/gh-aDotInTheVoid/rust2/build/aarch64-unknown-linux-gnu/test/rustdoc-json/reexport/pub_use_from_doc_hidden_mod/pub_use_from_doc_hidden_mod.json
------------------------------------------

As it has the following json (redacted)

  "index": {
    "0:0:1751": {
      "inner": {"module": {"is_crate": true, "is_stripped": false, "items": ["0:6-0:4:1750"]}},
      "name": "pub_use_from_doc_hidden_mod"
    },
    "0:6-0:4:1750": {
      "inner": {"import": {"glob": false, "id": "0:4:1750", "name": "Foo", "source": "__secrets::Foo"}},
      "name": null
    },

In HTML, Foo is inlined to the crate root.

Version: 28acba3c61246ba5974df332a064ab0c19b1cff8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/rustdoc-json/reexport/pub_use_from_doc_hidden_mod.rs and run the rustdoc-json test to reproduce the jsondoclint failure. Inspect the generated import ID for the re-export from the doc-hidden module; done when the JSON contains no dangling reference and jsondoclint passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.