Skip to content

Commit 5881fd5

Browse files
Display empty impl blocks if they have documentations
1 parent d35d972 commit 5881fd5

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,13 @@ fn render_impl(
16001600
}
16011601

16021602
if let Some(ref dox) = i.impl_item.collapsed_doc_value() {
1603+
if trait_.is_none() && i.inner_impl().items.is_empty() {
1604+
w.write_str(
1605+
"<div class=\"item-info\">\
1606+
<div class=\"stab empty-impl\">This impl block contains no items.</div>
1607+
</div>",
1608+
);
1609+
}
16031610
write!(
16041611
w,
16051612
"<div class=\"docblock\">{}</div>",

src/librustdoc/html/static/css/themes/ayu.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ details.undocumented > summary::before {
283283

284284
.stab.unstable,
285285
.stab.deprecated,
286-
.stab.portability {
286+
.stab.portability,
287+
.stab.empty-impl {
287288
color: #c5c5c5;
288289
background: #314559 !important;
289290
border-style: none !important;

src/librustdoc/html/static/css/themes/dark.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ details.undocumented > summary::before {
266266
color: #ddd;
267267
}
268268

269+
.stab.empty-impl { background: #FFF5D6; border-color: #FFC600; color: #2f2f2f; }
269270
.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #2f2f2f; }
270271
.stab.deprecated { background: #ffc4c4; border-color: #db7b7b; color: #2f2f2f; }
271272
.stab.portability { background: #F3DFFF; border-color: #b07bdb; color: #2f2f2f; }

src/librustdoc/html/static/css/themes/light.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ details.undocumented > summary::before {
255255
color: #000;
256256
}
257257

258+
.stab.empty-impl { background: #FFF5D6; border-color: #FFC600; }
258259
.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
259260
.stab.deprecated { background: #ffc4c4; border-color: #db7b7b; }
260261
.stab.portability { background: #F3DFFF; border-color: #b07bdb; }

src/librustdoc/passes/stripper.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ pub(crate) struct ImplStripper<'a> {
124124
impl<'a> DocFolder for ImplStripper<'a> {
125125
fn fold_item(&mut self, i: Item) -> Option<Item> {
126126
if let clean::ImplItem(ref imp) = *i.kind {
127-
// emptied none trait impls can be stripped
128-
if imp.trait_.is_none() && imp.items.is_empty() {
127+
// Impl blocks can be skipped if they are: empty; not a trait impl; and have no
128+
// documentation.
129+
if imp.trait_.is_none() && imp.items.is_empty() && i.doc_value().is_none() {
129130
return None;
130131
}
131132
if let Some(did) = imp.for_.def_id(self.cache) {

0 commit comments

Comments
 (0)