diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 486ca9b22539..b62d6b15cf36 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -341,7 +341,8 @@ summary.hideme,
.rustdoc-breadcrumbs,
.search-switcher,
/* This selector is for the items listed in the "all items" page. */
-ul.all-items {
+ul.all-items,
+.deprecated-count {
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
}
@@ -2652,6 +2653,14 @@ However, it's not needed with smaller screen width because the doc/code block is
display: none;
}
+.deprecated-count {
+ display: none;
+}
+.hide-deprecated-items .deprecated-count:not(:empty) {
+ display: block;
+ margin: 10px 0;
+}
+
/*
WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY
If you update this line, then you also need to update the line with the same warning
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 9961c1447ec2..55ff48846dcb 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -158,6 +158,7 @@ const REGEX_INVALID_TYPE_FILTER = /[^a-z]/ui;
const MAX_RESULTS = 200;
const NO_TYPE_FILTER = -1;
+const DEPRECATED_COUNT_SELECTOR = "deprecated-count";
/**
* The [edit distance] is a metric for measuring the difference between two strings.
@@ -4904,7 +4905,12 @@ async function addTab(results, query, display, finishedCallback, isTypeSearch) {
let output = document.createElement("ul");
output.className = "search-results " + extraClass;
+ const deprecatedCountElem = document.createElement("span");
+ deprecatedCountElem.className = DEPRECATED_COUNT_SELECTOR;
+ output.appendChild(deprecatedCountElem);
+
let count = 0;
+ let deprecatedCount = 0;
/** @type {Promise[]} */
const descList = [];
@@ -4922,6 +4928,10 @@ async function addTab(results, query, display, finishedCallback, isTypeSearch) {
link.className = "result-" + type;
if (obj.item.deprecated) {
link.className += " deprecated";
+ deprecatedCount += 1;
+ const plural = deprecatedCount > 1 ? "s" : "";
+ deprecatedCountElem.innerText =
+ `${deprecatedCount} deprecated item${plural} hidden by setting`;
}
link.href = obj.href;
@@ -5411,7 +5421,7 @@ function registerSearchEvents() {
const active = document.activeElement;
if (active) {
const previous = active.previousElementSibling;
- if (previous) {
+ if (previous && previous.className !== DEPRECATED_COUNT_SELECTOR) {
// @ts-expect-error
previous.focus();
} else {