Skip to content

Commit

Permalink
Auto merge of rust-lang#88456 - inquisitivecrystal:private-macro, r=j…
Browse files Browse the repository at this point in the history
…yn514

Fix: don't document private macros by default

As part of rust-lang#88019, I made it so private macros are documented in `--document-private-items` mode. Unfortunately, it appears that I also accidentally made them be documented when *not* in `--document-private-items` mode. This PR fixes that and adds a regression test.

r? `@jyn514` (I hope you don't mind that I keep sending PRs your way)

Fixes rust-lang#88453.
  • Loading branch information
bors committed Aug 30, 2021
2 parents 9556d7a + 6aacbd8 commit dbb0fe9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustdoc/passes/stripper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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(..) => {}
Expand Down
19 changes: 19 additions & 0 deletions src/test/rustdoc/macro-private-not-documented.rs
Original file line number Diff line number Diff line change
@@ -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 {
() => ()
}

0 comments on commit dbb0fe9

Please sign in to comment.