about summary refs log tree commit diff
path: root/src/librustdoc/html/render.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-07-16 17:08:59 -0700
committerGitHub <noreply@github.com>2020-07-16 17:08:59 -0700
commit0e70884083f8161e2abbb4a326a0dd0413e06f38 (patch)
tree04f327fdb1b1a01f3ce085950e5407de1c0678ef /src/librustdoc/html/render.rs
parent5751c7f1db9aced9aae5a1327fcdf67438aad59e (diff)
parent47fea961ba2cada1ca9a28f971cbe79ec525697e (diff)
downloadrust-0e70884083f8161e2abbb4a326a0dd0413e06f38.tar.gz
rust-0e70884083f8161e2abbb4a326a0dd0413e06f38.zip
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:
![image](https://user-images.githubusercontent.com/15225902/87501971-9cff8780-c68a-11ea-93b4-ea53ce18a77b.png)
After:
![image](https://user-images.githubusercontent.com/15225902/87501985-a7218600-c68a-11ea-81c0-a6b5b120832c.png)

Nothing changes in unstable items of std:
Before:
![image](https://user-images.githubusercontent.com/15225902/87502004-b7d1fc00-c68a-11ea-9224-a27a1d2a81d6.png)
After:
![image](https://user-images.githubusercontent.com/15225902/87502018-c0c2cd80-c68a-11ea-9773-4c63158025cb.png)

Closes  #54682
Diffstat (limited to 'src/librustdoc/html/render.rs')
-rw-r--r--src/librustdoc/html/render.rs45
1 files changed, 17 insertions, 28 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 31e35125dac..f872ed7010c 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -2230,12 +2230,15 @@ fn stability_tags(item: &clean::Item) -> String {
         tags += &tag_html("deprecated", message);
     }
 
-    if let Some(stab) = item.stability.as_ref().filter(|s| s.level == stability::Unstable) {
-        if stab.feature.as_deref() == Some("rustc_private") {
-            tags += &tag_html("internal", "Internal");
-        } else {
-            tags += &tag_html("unstable", "Experimental");
-        }
+    // The "rustc_private" crates are permanently unstable so it makes no sense
+    // to render "unstable" everywhere.
+    if item
+        .stability
+        .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 {
@@ -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) {
-        let is_rustc_private = stab.feature.as_deref() == Some("rustc_private");
-
-        let mut message = if is_rustc_private {
-            "<span class='emoji'>⚙️</span> This is an internal compiler API."
-        } else {
-            "<span class='emoji'>🔬</span> This is a nightly-only experimental API."
-        }
-        .to_owned();
+    // Render unstable items. But don't render "rustc_private" crates (internal compiler crates).
+    // Those crates are permanently unstable so it makes no sense to render "unstable" everywhere.
+    if let Some(stab) = item.stability.as_ref().filter(|stab| {
+        stab.level == stability::Unstable && stab.feature.as_deref() != Some("rustc_private")
+    }) {
+        let mut message =
+            "<span class='emoji'>🔬</span> This is a nightly-only experimental API.".to_owned();
 
         if let Some(feature) = stab.feature.as_deref() {
             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 {
-            // 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();
             message = format!(
                 "<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 {}'>{}</div>", class, message));
+        stability.push(format!("<div class='stab unstable'>{}</div>", message));
     }
 
     if let Some(ref cfg) = item.attrs.cfg {