From 71ff7ef17c260e1b29b58cdf359b50799d9449da Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 29 Mar 2023 16:16:02 +0200 Subject: [PATCH 1/2] Don't strip crate module --- src/librustdoc/passes/strip_hidden.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/passes/strip_hidden.rs b/src/librustdoc/passes/strip_hidden.rs index 890b3e8d67f7a..a688aa14863a9 100644 --- a/src/librustdoc/passes/strip_hidden.rs +++ b/src/librustdoc/passes/strip_hidden.rs @@ -121,9 +121,14 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> { // strip things like impl methods but when doing so // we must not add any items to the `retained` set. let old = mem::replace(&mut self.update_retained, false); - let ret = strip_item(self.set_is_in_hidden_item_and_fold(true, i)); + let ret = self.set_is_in_hidden_item_and_fold(true, i); self.update_retained = old; - Some(ret) + if ret.is_crate() { + // We don't strip the crate, even if it has `#[doc(hidden)]`. + Some(ret) + } else { + Some(strip_item(ret)) + } } _ => { let ret = self.set_is_in_hidden_item_and_fold(true, i); From cdc4fa45896c2b086646c8c9c91adb8d9dc5e45f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 29 Mar 2023 16:16:19 +0200 Subject: [PATCH 2/2] Add regression test for #109695 --- tests/rustdoc/issue-109695-crate-doc-hidden.rs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/rustdoc/issue-109695-crate-doc-hidden.rs diff --git a/tests/rustdoc/issue-109695-crate-doc-hidden.rs b/tests/rustdoc/issue-109695-crate-doc-hidden.rs new file mode 100644 index 0000000000000..7a3e53a0d32eb --- /dev/null +++ b/tests/rustdoc/issue-109695-crate-doc-hidden.rs @@ -0,0 +1,8 @@ +// This test ensures that even if the crate module is `#[doc(hidden)]`, the file +// is generated. + +// @has 'foo/index.html' +// @has 'foo/all.html' + +#![crate_name = "foo"] +#![doc(hidden)]