From 3ee6d0b6b6c4e00b062cbb0ecfc6070972ad0f20 Mon Sep 17 00:00:00 2001 From: inquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com> Date: Sun, 29 Aug 2021 00:07:42 -0700 Subject: [PATCH 1/2] Fix: don't document private macros by default --- src/librustdoc/passes/stripper.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index 4305268c9aab0..819d7d323fd7a 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -40,6 +40,7 @@ impl<'a> DocFolder for Stripper<'a> { | clean::UnionItem(..) | clean::AssocConstItem(..) | clean::TraitAliasItem(..) + | clean::MacroItem(..) | clean::ForeignTypeItem => { if i.def_id.is_local() { if !self.access_levels.is_exported(i.def_id.expect_def_id()) { @@ -70,8 +71,8 @@ impl<'a> DocFolder for Stripper<'a> { clean::ImplItem(..) => {} - // tymethods/macros have no control over privacy - clean::MacroItem(..) | clean::TyMethodItem(..) => {} + // tymethods have no control over privacy + clean::TyMethodItem(..) => {} // Proc-macros are always public clean::ProcMacroItem(..) => {} From 6aacbd87f4b9a5f0472c1b8c63414a0044b50bfd Mon Sep 17 00:00:00 2001 From: inquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com> Date: Sun, 29 Aug 2021 00:51:18 -0700 Subject: [PATCH 2/2] Add regression test --- .../rustdoc/macro-private-not-documented.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/test/rustdoc/macro-private-not-documented.rs diff --git a/src/test/rustdoc/macro-private-not-documented.rs b/src/test/rustdoc/macro-private-not-documented.rs new file mode 100644 index 0000000000000..ae8b0e7229f91 --- /dev/null +++ b/src/test/rustdoc/macro-private-not-documented.rs @@ -0,0 +1,19 @@ +// Checks that private macros aren't documented by default. They +// should be still be documented in `--document-private-items` mode, +// but that's tested in `macro-document-private.rs`. +// +// +// This is a regression text for issue #88453. +#![feature(decl_macro)] + +// @!has macro_private_not_documented/index.html 'a_macro' +// @!has macro_private_not_documented/macro.a_macro.html +macro_rules! a_macro { + () => () +} + +// @!has macro_private_not_documented/index.html 'another_macro' +// @!has macro_private_not_documented/macro.another_macro.html +macro another_macro { + () => () +}