about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-10-22 00:43:23 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2018-10-22 00:43:23 +0200
commitb2f80ddf34124ac516139de751af3824ab190eef (patch)
tree5e9adb6d6fa48379e5d9d66abf534cd81a3fec04 /src
parentf729f4a75e1dda17cb7bcf1e649aec4c68ad9c75 (diff)
downloadrust-b2f80ddf34124ac516139de751af3824ab190eef.tar.gz
rust-b2f80ddf34124ac516139de751af3824ab190eef.zip
Fix multiple errors
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/mod.rs9
-rw-r--r--src/librustdoc/html/render.rs9
-rw-r--r--src/librustdoc/html/static/main.js18
-rw-r--r--src/test/rustdoc/assoc-consts.rs2
-rw-r--r--src/test/rustdoc/manual_impl.rs2
5 files changed, 30 insertions, 10 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index db605e57735..f7f2a45255e 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -552,6 +552,15 @@ impl ItemEnum {
             _ => return None,
         })
     }
+
+    pub fn is_associated(&self) -> bool {
+        match *self {
+            ItemEnum::TypedefItem(_, _) |
+            ItemEnum::AssociatedConstItem(_, _) |
+            ItemEnum::AssociatedTypeItem(_, _) => true,
+            _ => false,
+        }
+    }
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index bb95696c513..72a1a30387c 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -3881,19 +3881,21 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
             RenderMode::ForDeref { mut_: deref_mut_ } => should_render_item(&item, deref_mut_),
         };
 
-        let (mut is_hidden, extra_class) = if item.doc_value().is_some() {
+        let (is_hidden, extra_class) = if trait_.is_none() ||
+                                          item.doc_value().is_some() ||
+                                          item.inner.is_associated() {
             (false, "")
         } else {
             (true, " hidden")
         };
         match item.inner {
             clean::MethodItem(clean::Method { ref decl, .. }) |
-            clean::TyMethodItem(clean::TyMethod{ ref decl, .. }) => {
+            clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => {
                 // Only render when the method is not static or we allow static methods
                 if render_method_item {
                     let id = cx.derive_id(format!("{}.{}", item_type, name));
                     let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
-                    write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
+                    write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
                     write!(w, "{}", spotlight_decl(decl)?)?;
                     write!(w, "<span id='{}' class='invisible'>", ns_id)?;
                     write!(w, "<table class='table-display'><tbody><tr><td><code>")?;
@@ -3910,7 +3912,6 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
                         render_stability_since_raw(w, item.stable_since(), outer_version)?;
                     }
                     write!(w, "</td></tr></tbody></table></span></h4>")?;
-                    is_hidden = false;
                 }
             }
             clean::TypedefItem(ref tydef, _) => {
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index dbcb2df3cf9..23da4dfbbbd 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -2059,12 +2059,22 @@
     onEach(document.getElementsByClassName('impl'), func);
     onEach(document.getElementsByClassName('impl-items'), function(e) {
         onEach(e.getElementsByClassName('associatedconstant'), func);
-        if (e.getElementsByClassName('hidden').length > 0) {
+        var hiddenElems = e.getElementsByClassName('hidden');
+        var needToggle = false;
+
+        for (var i = 0; i < hiddenElems.length; ++i) {
+            if (hasClass(hiddenElems[i], "content") === false &&
+                hasClass(hiddenElems[i], "docblock") === false) {
+                needToggle = true;
+                break;
+            }
+        }
+        if (needToggle === true) {
             var newToggle = document.createElement('a');
             newToggle.href = 'javascript:void(0)';
             newToggle.className = 'collapse-toggle hidden-default collapsed';
             newToggle.innerHTML = "[<span class='inner'>" + labelForToggleButton(true) + "</span>" +
-                                  "] Show hidden default items";
+                                  "] Show hidden undocumented items";
             newToggle.onclick = function() {
                 if (hasClass(this, "collapsed")) {
                     removeClass(this, "collapsed");
@@ -2075,7 +2085,7 @@
                         }
                     }, true);
                     this.innerHTML = "[<span class='inner'>" + labelForToggleButton(false) +
-                                     "</span>] Hide default items"
+                                     "</span>] Hide undocumented items"
                 } else {
                     addClass(this, "collapsed");
                     onEach(this.parentNode.getElementsByClassName("x"), function(x) {
@@ -2085,7 +2095,7 @@
                         }
                     }, true);
                     this.innerHTML = "[<span class='inner'>" + labelForToggleButton(true) +
-                                     "</span>] Show hidden default items";
+                                     "</span>] Show hidden undocumented items";
                 }
             };
             e.insertBefore(newToggle, e.firstChild);
diff --git a/src/test/rustdoc/assoc-consts.rs b/src/test/rustdoc/assoc-consts.rs
index 9ace8714918..d4f8e614ad0 100644
--- a/src/test/rustdoc/assoc-consts.rs
+++ b/src/test/rustdoc/assoc-consts.rs
@@ -99,7 +99,7 @@ impl Qux for Bar {
     /// Docs for QUX1 in impl.
     const QUX1: i8 = 5;
     // @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
-    // @has - '//*[@class="docblock hidden"]' "Docs for QUX_DEFAULT12 in trait."
+    // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
     const QUX_DEFAULT0: u16 = 6;
     // @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
     // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl."
diff --git a/src/test/rustdoc/manual_impl.rs b/src/test/rustdoc/manual_impl.rs
index 54a8a764833..ea46dae4f83 100644
--- a/src/test/rustdoc/manual_impl.rs
+++ b/src/test/rustdoc/manual_impl.rs
@@ -74,7 +74,7 @@ impl T for S2 {
 // @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
 // @has  - '//*[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
 // @has  - '//*[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
-// @has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
+// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait a_method definition.'
 pub struct S3(usize);
 
 /// Docs associated with the S3 trait implementation.