about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndy Russell <arussell123@gmail.com>2018-12-12 22:51:04 -0500
committerAndy Russell <arussell123@gmail.com>2018-12-20 13:47:39 -0500
commit8d393bf797c378bddc757cf18c59728b180ef2ba (patch)
tree3335b05c918354c7e78d3428263c6bfb339a5e09
parent5f3431691dd2b2b2b3c48ad5bfa6ca782a9a6d09 (diff)
downloadrust-8d393bf797c378bddc757cf18c59728b180ef2ba.tar.gz
rust-8d393bf797c378bddc757cf18c59728b180ef2ba.zip
display rustc_private APIs as "Internal"
-rw-r--r--src/librustdoc/html/render.rs38
-rw-r--r--src/librustdoc/html/static/rustdoc.css2
-rw-r--r--src/librustdoc/html/static/themes/dark.css5
-rw-r--r--src/librustdoc/html/static/themes/light.css5
-rw-r--r--src/test/rustdoc/internal.rs10
5 files changed, 52 insertions, 8 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 689054da39d..397eeb7433f 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -2703,13 +2703,16 @@ fn stability_tags(item: &clean::Item) -> String {
         tags.push_str("[<div class='stab deprecated'>Deprecated</div>] ");
     }
 
-    if item
+    if let Some(stab) = item
         .stability
         .as_ref()
         .filter(|s| s.level == stability::Unstable)
-        .is_some()
     {
-        tags.push_str("[<div class='stab unstable'>Experimental</div>] ");
+        if stab.feature.as_ref().map(|s| &**s) == Some("rustc_private") {
+            tags.push_str("[<div class='stab internal'>Internal</div>] ");
+        } else {
+            tags.push_str("[<div class='stab unstable'>Experimental</div>] ");
+        }
     }
 
     if let Some(ref cfg) = item.attrs.cfg {
@@ -2752,9 +2755,14 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
         .as_ref()
         .filter(|stab| stab.level == stability::Unstable)
     {
-        let mut message = String::from(
-            "<span class=microscope>🔬</span> This is a nightly-only experimental API.",
-        );
+        let is_rustc_private = stab.feature.as_ref().map(|s| &**s) == 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();
 
         if let Some(feature) = stab.feature.as_ref() {
             let mut feature = format!("<code>{}</code>", Escape(&feature));
@@ -2770,6 +2778,17 @@ 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>",
@@ -2778,7 +2797,12 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
             );
         }
 
-        stability.push(format!("<div class='stab unstable'>{}</div>", message))
+        let class = if is_rustc_private {
+            "internal"
+        } else {
+            "unstable"
+        };
+        stability.push(format!("<div class='stab {}'>{}</div>", class, message));
     }
 
     if let Some(ref cfg) = item.attrs.cfg {
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index cd5a8a739d1..b1648fbb1bc 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -765,7 +765,7 @@ body.blur > :not(#help) {
 	display: list-item;
 }
 
-.stab .microscope {
+.stab .emoji {
 	font-size: 1.5em;
 }
 
diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css
index 2cd1a858089..be3ffed2b26 100644
--- a/src/librustdoc/html/static/themes/dark.css
+++ b/src/librustdoc/html/static/themes/dark.css
@@ -174,6 +174,10 @@ a {
 	color: #D2991D;
 }
 
+.stab.internal a {
+	color: #304FFE;
+}
+
 a.test-arrow {
 	color: #dedede;
 }
@@ -199,6 +203,7 @@ a.test-arrow {
 }
 
 .stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #404040; }
+.stab.internal { background: #FFB9B3; border-color: #B71C1C; color: #404040; }
 .stab.deprecated { background: #F3DFFF; border-color: #7F0087;  color: #404040; }
 .stab.portability { background: #C4ECFF; border-color: #7BA5DB;  color: #404040; }
 
diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css
index 4cf35f64d19..4ae10492ae6 100644
--- a/src/librustdoc/html/static/themes/light.css
+++ b/src/librustdoc/html/static/themes/light.css
@@ -174,6 +174,10 @@ a {
 	color: #3873AD;
 }
 
+.stab.internal a {
+	color: #304FFE;
+}
+
 a.test-arrow {
 	color: #f5f5f5;
 }
@@ -200,6 +204,7 @@ a.test-arrow {
 }
 
 .stab.unstable { background: #FFF5D6; border-color: #FFC600; }
+.stab.internal { background: #FFB9B3; border-color: #B71C1C; }
 .stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
 .stab.portability { background: #C4ECFF; border-color: #7BA5DB; }
 
diff --git a/src/test/rustdoc/internal.rs b/src/test/rustdoc/internal.rs
new file mode 100644
index 00000000000..ba58da138a8
--- /dev/null
+++ b/src/test/rustdoc/internal.rs
@@ -0,0 +1,10 @@
+// compile-flags: -Z force-unstable-if-unmarked
+
+// @matches internal/index.html '//*[@class="docblock-short"]' \
+//      '^\[Internal\] Docs'
+// @has internal/struct.S.html '//*[@class="stab internal"]' \
+//      'This is an internal compiler API. (rustc_private)'
+/// Docs
+pub struct S;
+
+fn main() {}