diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2022-10-27 21:48:54 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2022-10-29 11:56:08 +0200 |
| commit | 0ef36b89459956af005b4186e4321f7f0376ec7d (patch) | |
| tree | fcffbce8b0ddbff587992f100c7b070f575ad701 | |
| parent | f0234f1976564c541d6aa1f04312e5acc22b2f3e (diff) | |
| download | rust-0ef36b89459956af005b4186e4321f7f0376ec7d.tar.gz rust-0ef36b89459956af005b4186e4321f7f0376ec7d.zip | |
Add regression test for missing item from private mod in JSON output
| -rw-r--r-- | src/librustdoc/passes/stripper.rs | 2 | ||||
| -rw-r--r-- | src/test/rustdoc-json/reexport/reexport_method_from_private_module.rs | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index 89efddf76ef..0089ce63d07 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -161,7 +161,7 @@ impl<'a> ImplStripper<'a> { } else if self.is_json_output { // If the "for" item is exported and the impl block isn't `#[doc(hidden)]`, then we // need to keep it. - self.cache.access_levels.is_exported(for_def_id) + self.cache.effective_visibilities.is_exported(for_def_id) && !item.attrs.lists(sym::doc).has_word(sym::hidden) } else { false diff --git a/src/test/rustdoc-json/reexport/reexport_method_from_private_module.rs b/src/test/rustdoc-json/reexport/reexport_method_from_private_module.rs new file mode 100644 index 00000000000..239b1a23b43 --- /dev/null +++ b/src/test/rustdoc-json/reexport/reexport_method_from_private_module.rs @@ -0,0 +1,28 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/102583>. + +// @set impl_S = "$.index[*][?(@.docs=='impl S')].id" +// @has "$.index[*][?(@.name=='S')].inner.impls[*]" $impl_S +// @set is_present = "$.index[*][?(@.name=='is_present')].id" +// @is "$.index[*][?(@.docs=='impl S')].inner.items[*]" $is_present +// @!has "$.index[*][?(@.name=='hidden_impl')]" +// @!has "$.index[*][?(@.name=='hidden_fn')]" + +#![no_std] + +mod private_mod { + pub struct S; + + /// impl S + impl S { + pub fn is_present() {} + #[doc(hidden)] + pub fn hidden_fn() {} + } + + #[doc(hidden)] + impl S { + pub fn hidden_impl() {} + } +} + +pub use private_mod::*; |
