Skip to content

rustdoc-json: Dangling ID when pub useing item from #[doc(hidden)] module #117718

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

Open
aDotInTheVoid opened this issue Nov 8, 2023 · 5 comments
Labels
A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@aDotInTheVoid
Copy link
Member

aDotInTheVoid commented Nov 8, 2023

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: 28acba3

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 8, 2023
@aDotInTheVoid aDotInTheVoid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-json Area: Rustdoc JSON backend and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 8, 2023
@GuillaumeGomez GuillaumeGomez changed the title rustdoc-json: Danging ID when pub useing item from #[doc(hidden)] module rustdoc-json: Dangling ID when pub useing item from #[doc(hidden)] module Nov 9, 2023
@GuillaumeGomez
Copy link
Member

Do you plan to work on it? Otherwise I'll do it in the next days.

@aDotInTheVoid
Copy link
Member Author

Go ahead, I'd be happy to review

@GuillaumeGomez
Copy link
Member

Thanks in advance then. :)

@GuillaumeGomez
Copy link
Member

So there seems to have multiple issues around reexports in the JSON output format. For example:

pub mod submodule {
    #[doc(hidden)]
    pub struct Hidden {}
}

pub use submodule::Hidden as UsedHidden;

Neither UsedHidden nor Hidden are generated in the output JSON, which is problematic. Based on that, I suppose we want to follow the rules of the HTML output and inline UsedHidden. Same goes for pub use __secrets::Foo;.

@GuillaumeGomez
Copy link
Member

From what I can see, we simply keep (some) private items around, I suppose we should do the same with doc(hidden).

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 T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
3 participants