Skip to content

Commit

Permalink
Prefer pub(crate) over no modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
camelid committed Dec 26, 2020
1 parent 00652e4 commit b959c75
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/decl_macro_priv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down
8 changes: 4 additions & 4 deletions src/test/rustdoc/pub-restricted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit b959c75

Please sign in to comment.