Prefer `pub(crate)` over no modifier

This commit is contained in:
Camelid 2020-12-25 16:16:40 -08:00
parent 00652e429a
commit b959c75b31
3 changed files with 8 additions and 8 deletions

View File

@ -1099,12 +1099,12 @@ impl clean::Visibility {
clean::Visibility::Restricted(vis_did) => {
let parent_module = find_closest_parent_module(tcx, item_did);
if parent_module == Some(vis_did) {
if vis_did.index == CRATE_DEF_INDEX {
write!(f, "pub(crate) ")
} else if parent_module == Some(vis_did) {
// `pub(in foo)` where `foo` is the parent module
// is the same as no visibility modifier
Ok(())
} else if vis_did.index == CRATE_DEF_INDEX {
write!(f, "pub(crate) ")
} else if parent_module
.map(|parent| find_closest_parent_module(tcx, parent))
.flatten()

View File

@ -2,7 +2,7 @@
#![feature(decl_macro)]
// @has decl_macro_priv/macro.crate_macro.html //pre 'macro crate_macro() {'
// @has decl_macro_priv/macro.crate_macro.html //pre 'pub(crate) macro crate_macro() {'
// @has - //pre '...'
// @has - //pre '}'
pub(crate) macro crate_macro() {}

View File

@ -6,13 +6,13 @@
// @has 'foo/struct.FooPublic.html' '//pre' 'pub struct FooPublic'
pub struct FooPublic;
// @has 'foo/struct.FooJustCrate.html' '//pre' 'struct FooJustCrate'
// @has 'foo/struct.FooJustCrate.html' '//pre' 'pub(crate) struct FooJustCrate'
crate struct FooJustCrate;
// @has 'foo/struct.FooPubCrate.html' '//pre' 'struct FooPubCrate'
// @has 'foo/struct.FooPubCrate.html' '//pre' 'pub(crate) struct FooPubCrate'
pub(crate) struct FooPubCrate;
// @has 'foo/struct.FooSelf.html' '//pre' 'struct FooSelf'
// @has 'foo/struct.FooSelf.html' '//pre' 'pub(crate) struct FooSelf'
pub(self) struct FooSelf;
// @has 'foo/struct.FooInSelf.html' '//pre' 'struct FooInSelf'
// @has 'foo/struct.FooInSelf.html' '//pre' 'pub(crate) struct FooInSelf'
pub(in self) struct FooInSelf;
mod a {
// @has 'foo/a/struct.FooASuper.html' '//pre' 'pub(crate) struct FooASuper'