Rollup merge of #109726 - GuillaumeGomez:doc-hidden-crate, r=notriddle

rustdoc: Don't strip crate module

Until we decide something for https://github.com/rust-lang/rust/issues/109695, rustdoc won't crash anymore because the crate folder doesn't exist.

r? `@notriddle`
This commit is contained in:
Matthias Krüger 2023-03-29 21:19:51 +02:00 committed by GitHub
commit 02cb4da896
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -121,9 +121,14 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
// 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);

View File

@ -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)]