Skip to content

Commit 00652e4

Browse files
committed
Handle pub(super)
1 parent 50c1c27 commit 00652e4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/librustdoc/html/format.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,12 +1097,20 @@ impl clean::Visibility {
10971097
clean::Inherited => Ok(()),
10981098

10991099
clean::Visibility::Restricted(vis_did) => {
1100-
if find_closest_parent_module(tcx, item_did) == Some(vis_did) {
1100+
let parent_module = find_closest_parent_module(tcx, item_did);
1101+
1102+
if parent_module == Some(vis_did) {
11011103
// `pub(in foo)` where `foo` is the parent module
11021104
// is the same as no visibility modifier
11031105
Ok(())
11041106
} else if vis_did.index == CRATE_DEF_INDEX {
11051107
write!(f, "pub(crate) ")
1108+
} else if parent_module
1109+
.map(|parent| find_closest_parent_module(tcx, parent))
1110+
.flatten()
1111+
== Some(vis_did)
1112+
{
1113+
write!(f, "pub(super) ")
11061114
} else {
11071115
f.write_str("pub(")?;
11081116
let path = tcx.def_path(vis_did);

0 commit comments

Comments
 (0)