diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index d71cc15a4576f..68d8335400126 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -2682,6 +2682,13 @@ function hideThemeButtonState() {
inner_toggle.onclick = toggleClicked;
e.insertBefore(inner_toggle, e.firstChild);
impl_call(e.previousSibling, inner_toggle);
+
+ // If *all* the items are hidden by default, remove the unnecessary indirection
+ // by toggling the items to be visible and removing the toggle.
+ if (e.childElementCount - 1 === hiddenElems.length) {
+ inner_toggle.click();
+ e.removeChild(inner_toggle);
+ }
}
});