diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-09 00:03:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-09 00:03:37 +0200 |
| commit | 5e388ea48e17a245b4113fe56bf6832caecb6d9e (patch) | |
| tree | 852326c8f4f256b9b7a5f47f7d0a37dae160fd3d | |
| parent | 5f0461707a10a2d5c9c90bf3bdb7c51f772515b9 (diff) | |
| parent | c2a0d9ca6eccbfaf1c6cd189dca0216a0ac66c75 (diff) | |
| download | rust-5e388ea48e17a245b4113fe56bf6832caecb6d9e.tar.gz rust-5e388ea48e17a245b4113fe56bf6832caecb6d9e.zip | |
Rollup merge of #128834 - its-the-shrimp:fix_101105, r=aDotInTheVoid
rustdoc: strip unreachable modules Modules are now stripped based on the same logic that's used to strip other item kinds Fixes #101105
| -rw-r--r-- | src/librustdoc/passes/stripper.rs | 9 | ||||
| -rw-r--r-- | tests/rustdoc-json/pub_mod_in_private_mod.rs | 6 |
2 files changed, 14 insertions, 1 deletions
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 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> { } 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 {} +} |
