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 {} +}