Prefer pub(crate)
over no modifier
This commit is contained in:
parent
00652e429a
commit
b959c75b31
3 changed files with 8 additions and 8 deletions
|
@ -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()
|
||||
|
|
|
@ -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() {}
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Add table
Reference in a new issue