Skip to content

Conversation

GuillaumeGomez
Copy link
Member

This PR fixes this bug:

mod private_module {
    #[doc(hidden)]
    pub struct Public;
}

pub use crate::private_module::Public as Foo;

pub use crate::private_module::Public as Foo; should be visible in the generated doc (and not inlined!) but currently isn't. This PR fixes it.

r? @notriddle

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 30, 2023
let Some(item_def_id) = reexport_chain(tcx, def_id, res_did).iter()
let is_hidden = tcx.is_doc_hidden(ori_res_did);
let item = tcx.hir().get_by_def_id(res_did);
let is_module = matches!(item, Node::Item(&hir::Item { kind: hir::ItemKind::Mod(_), .. }));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it matter if it's a module or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if it's a module, it can contain items that could be re-exported and we need to to go through them too. A good example of this can be seen in tests/rustdoc/infinite-redirection.rs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment explaining it and moved this matches!() directly into the if condition.

@GuillaumeGomez GuillaumeGomez force-pushed the reexport-doc-hidden-private branch from cd4dd39 to 9906504 Compare May 30, 2023 18:28
@GuillaumeGomez GuillaumeGomez changed the title Reexport doc hidden private Fix re-export of doc hidden item inside private item not displayed May 30, 2023
@notriddle
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented May 30, 2023

📌 Commit 9906504 has been approved by notriddle

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#112031 (Migrate  `item_proc_macro` to Askama)
 - rust-lang#112053 (Remove `-Zcgu-partitioning-strategy`.)
 - rust-lang#112069 (offset_of: don't require type to be `Sized`)
 - rust-lang#112084 (enhancements on  build_helper utilization and rustdoc-gui-test)
 - rust-lang#112096 (Remove array_zip)
 - rust-lang#112108 (Fix re-export of doc hidden item inside private item not displayed)
 - rust-lang#112113 (rustdoc: simplify `clean` by removing `FnRetTy`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1d643e1 into rust-lang:master May 31, 2023
@rustbot rustbot added this to the 1.72.0 milestone May 31, 2023
@GuillaumeGomez GuillaumeGomez deleted the reexport-doc-hidden-private branch May 31, 2023 10:24
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 15, 2023
…ddle

Add chapter in rustdoc book for re-exports and add a regression test for `#[doc(hidden)]` behaviour

Fixes rust-lang#109449.
Fixes rust-lang#53417.

After the discussion in rust-lang#109697, I made a few PRs to fix a few corner cases:
 * rust-lang#112178
 * rust-lang#112108
 * rust-lang#111997

With this I think I covered all cases. Only thing missing at this point was a chapter covering re-exports in the rustdoc book.

r? `@notriddle`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants