From c2a0d9ca6eccbfaf1c6cd189dca0216a0ac66c75 Mon Sep 17 00:00:00 2001 From: schvv31n Date: Thu, 8 Aug 2024 17:13:15 +0100 Subject: [PATCH] rustdoc: fixed #101105 modules are now stripped based on the same logic that's used to strip other item kinds --- src/librustdoc/passes/stripper.rs | 9 ++++++++- tests/rustdoc-json/pub_mod_in_private_mod.rs | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/rustdoc-json/pub_mod_in_private_mod.rs diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index d1e2b9978f7..f807c3362c4 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -95,7 +95,14 @@ fn fold_item(&mut self, i: Item) -> Option { } clean::ModuleItem(..) => { - if i.item_id.is_local() && i.visibility(self.tcx) != Some(Visibility::Public) { + if i.item_id.is_local() + && !is_item_reachable( + self.tcx, + self.is_json_output, + self.effective_visibilities, + i.item_id, + ) + { debug!("Stripper: stripping module {:?}", i.name); let old = mem::replace(&mut self.update_retained, false); let ret = strip_item(self.fold_item_recur(i)); diff --git a/tests/rustdoc-json/pub_mod_in_private_mod.rs b/tests/rustdoc-json/pub_mod_in_private_mod.rs new file mode 100644 index 00000000000..112ab9c68f0 --- /dev/null +++ b/tests/rustdoc-json/pub_mod_in_private_mod.rs @@ -0,0 +1,6 @@ +// See https://github.com/rust-lang/rust/issues/101105 + +//@ !has "$.index[*][?(@.name=='nucleus')]" +mod corpus { + pub mod nucleus {} +}