diff options
| author | Camelid <camelidcamel@gmail.com> | 2020-12-25 15:54:04 -0800 |
|---|---|---|
| committer | Camelid <camelidcamel@gmail.com> | 2020-12-25 15:54:04 -0800 |
| commit | 00652e429aaa2250f2561a457e46387bb5b16737 (patch) | |
| tree | 6075ebdb8e588b975a9a38b6001195106f9f9a57 /src/librustdoc | |
| parent | 50c1c27fa6adbb20ce61fce7caaea489e3984265 (diff) | |
| download | rust-00652e429aaa2250f2561a457e46387bb5b16737.tar.gz rust-00652e429aaa2250f2561a457e46387bb5b16737.zip | |
Handle `pub(super)`
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/html/format.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 6a611ccf58e..a8eae52fc56 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1097,12 +1097,20 @@ impl clean::Visibility { clean::Inherited => Ok(()), clean::Visibility::Restricted(vis_did) => { - if find_closest_parent_module(tcx, item_did) == Some(vis_did) { + let parent_module = find_closest_parent_module(tcx, item_did); + + 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() + == Some(vis_did) + { + write!(f, "pub(super) ") } else { f.write_str("pub(")?; let path = tcx.def_path(vis_did); |
