Rollup merge of #74351 - lzutao:remove-rustc-internal-compiler-warns, r=Mark-Simulacrum
Do not render unstable items for rustc doc See the zulip conversion: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/rustc.20doc.3A.20.22internal.20compiler.20API.22.20warns.20are.20everywhere!/near/203850782 Before:  After:  Nothing changes in unstable items of std: Before:  After:  Closes #54682
This commit is contained in:
commit
0e70884083
@ -2230,12 +2230,15 @@ fn stability_tags(item: &clean::Item) -> String {
|
|||||||
tags += &tag_html("deprecated", message);
|
tags += &tag_html("deprecated", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(stab) = item.stability.as_ref().filter(|s| s.level == stability::Unstable) {
|
// The "rustc_private" crates are permanently unstable so it makes no sense
|
||||||
if stab.feature.as_deref() == Some("rustc_private") {
|
// to render "unstable" everywhere.
|
||||||
tags += &tag_html("internal", "Internal");
|
if item
|
||||||
} else {
|
.stability
|
||||||
tags += &tag_html("unstable", "Experimental");
|
.as_ref()
|
||||||
}
|
.map(|s| s.level == stability::Unstable && s.feature.as_deref() != Some("rustc_private"))
|
||||||
|
== Some(true)
|
||||||
|
{
|
||||||
|
tags += &tag_html("unstable", "Experimental");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref cfg) = item.attrs.cfg {
|
if let Some(ref cfg) = item.attrs.cfg {
|
||||||
@ -2286,15 +2289,13 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(stab) = item.stability.as_ref().filter(|stab| stab.level == stability::Unstable) {
|
// Render unstable items. But don't render "rustc_private" crates (internal compiler crates).
|
||||||
let is_rustc_private = stab.feature.as_deref() == Some("rustc_private");
|
// Those crates are permanently unstable so it makes no sense to render "unstable" everywhere.
|
||||||
|
if let Some(stab) = item.stability.as_ref().filter(|stab| {
|
||||||
let mut message = if is_rustc_private {
|
stab.level == stability::Unstable && stab.feature.as_deref() != Some("rustc_private")
|
||||||
"<span class='emoji'>⚙️</span> This is an internal compiler API."
|
}) {
|
||||||
} else {
|
let mut message =
|
||||||
"<span class='emoji'>🔬</span> This is a nightly-only experimental API."
|
"<span class='emoji'>🔬</span> This is a nightly-only experimental API.".to_owned();
|
||||||
}
|
|
||||||
.to_owned();
|
|
||||||
|
|
||||||
if let Some(feature) = stab.feature.as_deref() {
|
if let Some(feature) = stab.feature.as_deref() {
|
||||||
let mut feature = format!("<code>{}</code>", Escape(&feature));
|
let mut feature = format!("<code>{}</code>", Escape(&feature));
|
||||||
@ -2310,17 +2311,6 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(unstable_reason) = &stab.unstable_reason {
|
if let Some(unstable_reason) = &stab.unstable_reason {
|
||||||
// Provide a more informative message than the compiler help.
|
|
||||||
let unstable_reason = if is_rustc_private {
|
|
||||||
"This crate is being loaded from the sysroot, a permanently unstable location \
|
|
||||||
for private compiler dependencies. It is not intended for general use. Prefer \
|
|
||||||
using a public version of this crate from \
|
|
||||||
[crates.io](https://crates.io) via [`Cargo.toml`]\
|
|
||||||
(https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html)."
|
|
||||||
} else {
|
|
||||||
unstable_reason
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut ids = cx.id_map.borrow_mut();
|
let mut ids = cx.id_map.borrow_mut();
|
||||||
message = format!(
|
message = format!(
|
||||||
"<details><summary>{}</summary>{}</details>",
|
"<details><summary>{}</summary>{}</details>",
|
||||||
@ -2336,8 +2326,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let class = if is_rustc_private { "internal" } else { "unstable" };
|
stability.push(format!("<div class='stab unstable'>{}</div>", message));
|
||||||
stability.push(format!("<div class='stab {}'>{}</div>", class, message));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref cfg) = item.attrs.cfg {
|
if let Some(ref cfg) = item.attrs.cfg {
|
||||||
|
@ -216,10 +216,6 @@ a {
|
|||||||
color: #39AFD7;
|
color: #39AFD7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stab.internal a {
|
|
||||||
color: #304FFE;
|
|
||||||
}
|
|
||||||
|
|
||||||
.collapse-toggle {
|
.collapse-toggle {
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
@ -254,7 +250,6 @@ a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.stab.unstable,
|
.stab.unstable,
|
||||||
.stab.internal,
|
|
||||||
.stab.deprecated,
|
.stab.deprecated,
|
||||||
.stab.portability {
|
.stab.portability {
|
||||||
color: #c5c5c5;
|
color: #c5c5c5;
|
||||||
@ -462,7 +457,6 @@ pre.rust .doccomment {}
|
|||||||
.content .highlighted.type {}
|
.content .highlighted.type {}
|
||||||
pre.rust .kw-2,pre.rust .prelude-ty {}
|
pre.rust .kw-2,pre.rust .prelude-ty {}
|
||||||
.content span.trait,.content a.trait,.block a.current.trait {}
|
.content span.trait,.content a.trait,.block a.current.trait {}
|
||||||
.stab.internal {}
|
|
||||||
|
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
.sidebar-menu {
|
.sidebar-menu {
|
||||||
|
@ -172,10 +172,6 @@ a {
|
|||||||
color: #D2991D;
|
color: #D2991D;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stab.internal a {
|
|
||||||
color: #304FFE;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.test-arrow {
|
a.test-arrow {
|
||||||
color: #dedede;
|
color: #dedede;
|
||||||
}
|
}
|
||||||
@ -214,7 +210,6 @@ a.test-arrow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #2f2f2f; }
|
.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #2f2f2f; }
|
||||||
.stab.internal { background: #FFB9B3; border-color: #B71C1C; color: #2f2f2f; }
|
|
||||||
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #2f2f2f; }
|
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #2f2f2f; }
|
||||||
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #2f2f2f; }
|
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #2f2f2f; }
|
||||||
|
|
||||||
|
@ -173,10 +173,6 @@ a {
|
|||||||
color: #3873AD;
|
color: #3873AD;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stab.internal a {
|
|
||||||
color: #304FFE;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.test-arrow {
|
a.test-arrow {
|
||||||
color: #f5f5f5;
|
color: #f5f5f5;
|
||||||
}
|
}
|
||||||
@ -215,7 +211,6 @@ a.test-arrow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
|
.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
|
||||||
.stab.internal { background: #FFB9B3; border-color: #B71C1C; }
|
|
||||||
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
|
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
|
||||||
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; }
|
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; }
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
// compile-flags: -Z force-unstable-if-unmarked
|
// compile-flags: -Z force-unstable-if-unmarked
|
||||||
|
|
||||||
// @matches internal/index.html '//*[@class="docblock-short"]/span[@class="stab internal"]' \
|
// Check that the unstable marker is not added for "rustc_private".
|
||||||
// 'Internal'
|
|
||||||
|
// @!matches internal/index.html '//*[@class="docblock-short"]/span[@class="stab unstable"]'
|
||||||
|
// @!matches internal/index.html '//*[@class="docblock-short"]/span[@class="stab internal"]'
|
||||||
// @matches - '//*[@class="docblock-short"]' 'Docs'
|
// @matches - '//*[@class="docblock-short"]' 'Docs'
|
||||||
|
|
||||||
// @has internal/struct.S.html '//*[@class="stab internal"]' \
|
// @!has internal/struct.S.html '//*[@class="stab unstable"]'
|
||||||
// 'This is an internal compiler API. (rustc_private)'
|
// @!has internal/struct.S.html '//*[@class="stab internal"]'
|
||||||
/// Docs
|
/// Docs
|
||||||
pub struct S;
|
pub struct S;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user