Skip to content

File tree

5 files changed

+23
-48
lines changed

5 files changed

+23
-48
lines changed

src/librustdoc/html/render.rs

+17-28
Original file line numberDiff line numberDiff line change
@@ -2230,12 +2230,15 @@ fn stability_tags(item: &clean::Item) -> String {
22302230
tags += &tag_html("deprecated", message);
22312231
}
22322232

2233-
if let Some(stab) = item.stability.as_ref().filter(|s| s.level == stability::Unstable) {
2234-
if stab.feature.as_deref() == Some("rustc_private") {
2235-
tags += &tag_html("internal", "Internal");
2236-
} else {
2237-
tags += &tag_html("unstable", "Experimental");
2238-
}
2233+
// The "rustc_private" crates are permanently unstable so it makes no sense
2234+
// to render "unstable" everywhere.
2235+
if item
2236+
.stability
2237+
.as_ref()
2238+
.map(|s| s.level == stability::Unstable && s.feature.as_deref() != Some("rustc_private"))
2239+
== Some(true)
2240+
{
2241+
tags += &tag_html("unstable", "Experimental");
22392242
}
22402243

22412244
if let Some(ref cfg) = item.attrs.cfg {
@@ -2286,15 +2289,13 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
22862289
));
22872290
}
22882291

2289-
if let Some(stab) = item.stability.as_ref().filter(|stab| stab.level == stability::Unstable) {
2290-
let is_rustc_private = stab.feature.as_deref() == Some("rustc_private");
2291-
2292-
let mut message = if is_rustc_private {
2293-
"<span class='emoji'>⚙️</span> This is an internal compiler API."
2294-
} else {
2295-
"<span class='emoji'>🔬</span> This is a nightly-only experimental API."
2296-
}
2297-
.to_owned();
2292+
// Render unstable items. But don't render "rustc_private" crates (internal compiler crates).
2293+
// Those crates are permanently unstable so it makes no sense to render "unstable" everywhere.
2294+
if let Some(stab) = item.stability.as_ref().filter(|stab| {
2295+
stab.level == stability::Unstable && stab.feature.as_deref() != Some("rustc_private")
2296+
}) {
2297+
let mut message =
2298+
"<span class='emoji'>🔬</span> This is a nightly-only experimental API.".to_owned();
22982299

22992300
if let Some(feature) = stab.feature.as_deref() {
23002301
let mut feature = format!("<code>{}</code>", Escape(&feature));
@@ -2310,17 +2311,6 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
23102311
}
23112312

23122313
if let Some(unstable_reason) = &stab.unstable_reason {
2313-
// Provide a more informative message than the compiler help.
2314-
let unstable_reason = if is_rustc_private {
2315-
"This crate is being loaded from the sysroot, a permanently unstable location \
2316-
for private compiler dependencies. It is not intended for general use. Prefer \
2317-
using a public version of this crate from \
2318-
[crates.io](https://crates.io) via [`Cargo.toml`]\
2319-
(https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html)."
2320-
} else {
2321-
unstable_reason
2322-
};
2323-
23242314
let mut ids = cx.id_map.borrow_mut();
23252315
message = format!(
23262316
"<details><summary>{}</summary>{}</details>",
@@ -2336,8 +2326,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
23362326
);
23372327
}
23382328

2339-
let class = if is_rustc_private { "internal" } else { "unstable" };
2340-
stability.push(format!("<div class='stab {}'>{}</div>", class, message));
2329+
stability.push(format!("<div class='stab unstable'>{}</div>", message));
23412330
}
23422331

23432332
if let Some(ref cfg) = item.attrs.cfg {

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

-6
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,6 @@ a {
216216
color: #39AFD7;
217217
}
218218

219-
.stab.internal a {
220-
color: #304FFE;
221-
}
222-
223219
.collapse-toggle {
224220
color: #999;
225221
}
@@ -254,7 +250,6 @@ a {
254250
}
255251

256252
.stab.unstable,
257-
.stab.internal,
258253
.stab.deprecated,
259254
.stab.portability {
260255
color: #c5c5c5;
@@ -462,7 +457,6 @@ pre.rust .doccomment {}
462457
.content .highlighted.type {}
463458
pre.rust .kw-2,pre.rust .prelude-ty {}
464459
.content span.trait,.content a.trait,.block a.current.trait {}
465-
.stab.internal {}
466460

467461
@media (max-width: 700px) {
468462
.sidebar-menu {

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

-5
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ a {
172172
color: #D2991D;
173173
}
174174

175-
.stab.internal a {
176-
color: #304FFE;
177-
}
178-
179175
a.test-arrow {
180176
color: #dedede;
181177
}
@@ -214,7 +210,6 @@ a.test-arrow {
214210
}
215211

216212
.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #2f2f2f; }
217-
.stab.internal { background: #FFB9B3; border-color: #B71C1C; color: #2f2f2f; }
218213
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #2f2f2f; }
219214
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #2f2f2f; }
220215

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

-5
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@ a {
173173
color: #3873AD;
174174
}
175175

176-
.stab.internal a {
177-
color: #304FFE;
178-
}
179-
180176
a.test-arrow {
181177
color: #f5f5f5;
182178
}
@@ -215,7 +211,6 @@ a.test-arrow {
215211
}
216212

217213
.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
218-
.stab.internal { background: #FFB9B3; border-color: #B71C1C; }
219214
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
220215
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; }
221216

src/test/rustdoc/internal.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// compile-flags: -Z force-unstable-if-unmarked
22

3-
// @matches internal/index.html '//*[@class="docblock-short"]/span[@class="stab internal"]' \
4-
// 'Internal'
3+
// Check that the unstable marker is not added for "rustc_private".
4+
5+
// @!matches internal/index.html '//*[@class="docblock-short"]/span[@class="stab unstable"]'
6+
// @!matches internal/index.html '//*[@class="docblock-short"]/span[@class="stab internal"]'
57
// @matches - '//*[@class="docblock-short"]' 'Docs'
68

7-
// @has internal/struct.S.html '//*[@class="stab internal"]' \
8-
// 'This is an internal compiler API. (rustc_private)'
9+
// @!has internal/struct.S.html '//*[@class="stab unstable"]'
10+
// @!has internal/struct.S.html '//*[@class="stab internal"]'
911
/// Docs
1012
pub struct S;
1113

0 commit comments

Comments
 (0)