about summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-02-20 10:14:28 +0000
committerbors <bors@rust-lang.org>2019-02-20 10:14:28 +0000
commitf66e4697ae286985ddefc53c3a047614568458bb (patch)
tree656e63ba3f96698e771c822a90670f7eb608aa51 /src/librustdoc/html
parent74e35d270067afff72034312065c48e6d8cfba67 (diff)
parenta1a17f5c6663a6a22a58505a6a925b44dfc016e9 (diff)
Auto merge of #58578 - kennytm:rollup, r=kennytm
Rollup of 24 pull requests

Successful merges:

 - #56470 (Modify doctest's auto-`fn main()` to allow `Result`s)
 - #58044 (Make overflowing and wrapping negation const)
 - #58303 (Improve stability tags display)
 - #58336 (Fix search results interactions)
 - #58384 (Fix tables display)
 - #58392 (Use less explicit shifting in std::net::ip)
 - #58409 (rustdoc: respect alternate flag when formatting impl trait)
 - #58456 (Remove no longer accurate diagnostic code about NLL)
 - #58528 (Don't use an allocation for ItemId in StmtKind)
 - #58530 (Monomorphize less code in fs::{read|write})
 - #58534 (Mention capping forbid lints)
 - #58536 (Remove UB in pointer tests)
 - #58538 (Add missing fmt structs examples)
 - #58539 (Add alias methods to PathBuf for underlying OsString (#58234))
 - #58544 (Fix doc for rustc "-g" flag)
 - #58545 (Add regression test for a specialization-related ICE (#39448))
 - #58546 (librustc_codegen_llvm => 2018)
 - #58551 (Explain a panic in test case net::tcp::tests::double_bind)
 - #58553 (Use more impl header lifetime elision)
 - #58562 (Fix style nits)
 - #58565 (Fix typo in std::future::Future docs)
 - #58568 (Fix a transposition in driver.rs.)
 - #58569 (Reduce Some Code Repetitions like `(n << amt) >> amt`)
 - #58576 (Stabilize iter::successors and iter::from_fn)
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/format.rs26
-rw-r--r--src/librustdoc/html/render.rs45
-rw-r--r--src/librustdoc/html/static/main.js4
-rw-r--r--src/librustdoc/html/static/rustdoc.css5
-rw-r--r--src/librustdoc/html/static/themes/dark.css22
-rw-r--r--src/librustdoc/html/static/themes/light.css22
6 files changed, 56 insertions, 68 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 4fbbaf0f2e1..df7835214eb 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -49,8 +49,11 @@ pub struct AbiSpace(pub Abi);
 pub struct Function<'a> {
     /// The declaration to emit.
     pub decl: &'a clean::FnDecl,
-    /// The length of the function's "name", used to determine line-wrapping.
-    pub name_len: usize,
+    /// The length of the function header and name. In other words, the number of characters in the
+    /// function declaration up to but not including the parentheses.
+    ///
+    /// Used to determine line-wrapping.
+    pub header_len: usize,
     /// The number of spaces to indent each successive line with, if line-wrapping is necessary.
     pub indent: usize,
     /// Whether the function is async or not.
@@ -675,7 +678,11 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
             }
         }
         clean::ImplTrait(ref bounds) => {
-            write!(f, "impl {}", GenericBounds(bounds))
+            if f.alternate() {
+                write!(f, "impl {:#}", GenericBounds(bounds))
+            } else {
+                write!(f, "impl {}", GenericBounds(bounds))
+            }
         }
         clean::QPath { ref name, ref self_type, ref trait_ } => {
             let should_show_cast = match *trait_ {
@@ -844,7 +851,7 @@ impl fmt::Display for clean::FnDecl {
 
 impl<'a> fmt::Display for Function<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let &Function { decl, name_len, indent, asyncness } = self;
+        let &Function { decl, header_len, indent, asyncness } = self;
         let amp = if f.alternate() { "&" } else { "&amp;" };
         let mut args = String::new();
         let mut args_plain = String::new();
@@ -899,6 +906,8 @@ impl<'a> fmt::Display for Function<'a> {
             }
         }
 
+        let mut args_plain = format!("({})", args_plain);
+
         if decl.variadic {
             args.push_str(",<br> ...");
             args_plain.push_str(", ...");
@@ -917,13 +926,8 @@ impl<'a> fmt::Display for Function<'a> {
             output.to_string()
         };
 
-        let pad = " ".repeat(name_len);
-        let plain = format!("{pad}({args}){arrow}",
-                        pad = pad,
-                        args = args_plain,
-                        arrow = arrow_plain);
-
-        let output = if plain.len() > 80 {
+        let declaration_len = header_len + args_plain.len() + arrow_plain.len();
+        let output = if declaration_len > 80 {
             let full_pad = format!("<br>{}", "&nbsp;".repeat(indent + 4));
             let close_pad = format!("<br>{}", "&nbsp;".repeat(indent));
             format!("({args}{close}){arrow}",
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 91ec88652cf..d037154272d 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -2787,8 +2787,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
                        <tr class='{stab}{add}module-item'>\
                            <td><a class=\"{class}\" href=\"{href}\" \
                                   title='{title}'>{name}</a>{unsafety_flag}</td>\
-                           <td class='docblock-short'>{stab_tags}{docs}\
-                           </td>\
+                           <td class='docblock-short'>{stab_tags}{docs}</td>\
                        </tr>",
                        name = *myitem.name.as_ref().unwrap(),
                        stab_tags = stability_tags(myitem),
@@ -2985,14 +2984,16 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
 
 fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
                  f: &clean::Function) -> fmt::Result {
-    let name_len = format!("{}{}{}{}{:#}fn {}{:#}",
-                           VisSpace(&it.visibility),
-                           ConstnessSpace(f.header.constness),
-                           UnsafetySpace(f.header.unsafety),
-                           AsyncSpace(f.header.asyncness),
-                           AbiSpace(f.header.abi),
-                           it.name.as_ref().unwrap(),
-                           f.generics).len();
+    let header_len = format!(
+        "{}{}{}{}{:#}fn {}{:#}",
+        VisSpace(&it.visibility),
+        ConstnessSpace(f.header.constness),
+        UnsafetySpace(f.header.unsafety),
+        AsyncSpace(f.header.asyncness),
+        AbiSpace(f.header.abi),
+        it.name.as_ref().unwrap(),
+        f.generics
+    ).len();
     write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it)?)?;
     render_attributes(w, it)?;
     write!(w,
@@ -3008,7 +3009,7 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
            where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true },
            decl = Function {
               decl: &f.decl,
-              name_len,
+              header_len,
               indent: 0,
               asyncness: f.header.asyncness,
            })?;
@@ -3423,16 +3424,18 @@ fn render_assoc_item(w: &mut fmt::Formatter,
                 href(did).map(|p| format!("{}#{}.{}", p.0, ty, name)).unwrap_or(anchor)
             }
         };
-        let mut head_len = format!("{}{}{}{}{:#}fn {}{:#}",
-                                   VisSpace(&meth.visibility),
-                                   ConstnessSpace(header.constness),
-                                   UnsafetySpace(header.unsafety),
-                                   AsyncSpace(header.asyncness),
-                                   AbiSpace(header.abi),
-                                   name,
-                                   *g).len();
+        let mut header_len = format!(
+            "{}{}{}{}{:#}fn {}{:#}",
+            VisSpace(&meth.visibility),
+            ConstnessSpace(header.constness),
+            UnsafetySpace(header.unsafety),
+            AsyncSpace(header.asyncness),
+            AbiSpace(header.abi),
+            name,
+            *g
+        ).len();
         let (indent, end_newline) = if parent == ItemType::Trait {
-            head_len += 4;
+            header_len += 4;
             (4, false)
         } else {
             (0, true)
@@ -3450,7 +3453,7 @@ fn render_assoc_item(w: &mut fmt::Formatter,
                generics = *g,
                decl = Function {
                    decl: d,
-                   name_len: head_len,
+                   header_len,
                    indent,
                    asyncness: header.asyncness,
                },
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index ff28c4f40bc..1849e53d937 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -1196,7 +1196,7 @@ if (!DOMTokenList.prototype.remove) {
                 var actives = [[], [], []];
                 // "current" is used to know which tab we're looking into.
                 var current = 0;
-                onEachLazy(document.getElementsByClassName("search-results"), function(e) {
+                onEachLazy(document.getElementById("results").childNodes, function(e) {
                     onEachLazy(e.getElementsByClassName("highlighted"), function(e) {
                         actives[current].push(e);
                     });
@@ -1213,7 +1213,7 @@ if (!DOMTokenList.prototype.remove) {
                     removeClass(actives[currentTab][0], "highlighted");
                 } else if (e.which === 40) { // down
                     if (!actives[currentTab].length) {
-                        var results = document.getElementsByClassName("search-results");
+                        var results = document.getElementById("results").childNodes;
                         if (results.length > 0) {
                             var res = results[currentTab].getElementsByClassName("result");
                             if (res.length > 0) {
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 4ec8637cc71..787f3c7f480 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -424,7 +424,8 @@ h4 > code, h3 > code, .invisible > code {
 
 .docblock table {
 	margin: .5em 0;
-	width: 100%;
+	width: calc(100% - 2px);
+	border: 1px dashed;
 }
 
 .docblock table td {
@@ -657,7 +658,7 @@ a {
 	transition: border-color 300ms ease;
 	transition: border-radius 300ms ease-in-out;
 	transition: box-shadow 300ms ease-in-out;
-	width: 100%;
+	width: calc(100% - 32px);
 }
 
 #crate-search + .search-input {
diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css
index 333fe76a8a4..e756ab60ccc 100644
--- a/src/librustdoc/html/static/themes/dark.css
+++ b/src/librustdoc/html/static/themes/dark.css
@@ -68,20 +68,10 @@ pre {
 	border-bottom-color: #DDD;
 }
 
-.docblock table {
+.docblock table, .docblock table td, .docblock table th {
 	border-color: #ddd;
 }
 
-.docblock table td {
-	border-top-color: #ddd;
-	border-bottom-color: #ddd;
-}
-
-.docblock table th {
-	border-top-color: #ddd;
-	border-bottom-color: #ddd;
-}
-
 .content .method .where,
 .content .fn .where,
 .content .where.fmt-newline {
@@ -190,15 +180,15 @@ a.test-arrow {
 	box-shadow: 1px 0 0 1px #000, 0 0 0 2px transparent;
 }
 
-.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; }
-
 .module-item .stab {
 	color: #ddd;
 }
 
+.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.portability { background: #C4ECFF; border-color: #7BA5DB; color: #2f2f2f; }
+
 #help > div {
 	background: #4d4d4d;
 	border-color: #bfbfbf;
diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css
index 19ae67b2988..a294f6f2ff1 100644
--- a/src/librustdoc/html/static/themes/light.css
+++ b/src/librustdoc/html/static/themes/light.css
@@ -67,21 +67,11 @@ pre {
 }
 
 .docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
-	border-bottom-color: #DDD;
-}
-
-.docblock table {
-	border-color: #ddd;
-}
-
-.docblock table td {
-	border-top-color: #ddd;
 	border-bottom-color: #ddd;
 }
 
-.docblock table th {
-	border-top-color: #ddd;
-	border-bottom-color: #ddd;
+.docblock table, .docblock table td, .docblock table th {
+	border-color: #ddd;
 }
 
 .content .method .where,
@@ -191,15 +181,15 @@ a.test-arrow {
 	box-shadow: 1px 0 0 1px #e0e0e0, 0 0 0 2px transparent;
 }
 
+.module-item .stab {
+	color: #000;
+}
+
 .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; }
 
-.module-item .stab {
-	color: #000;
-}
-
 #help > div {
 	background: #e9e9e9;
 	border-color: #bfbfbf;