Skip to content

Commit b2f80dd

Browse files
Fix multiple errors
1 parent f729f4a commit b2f80dd

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

src/librustdoc/clean/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,15 @@ impl ItemEnum {
552552
_ => return None,
553553
})
554554
}
555+
556+
pub fn is_associated(&self) -> bool {
557+
match *self {
558+
ItemEnum::TypedefItem(_, _) |
559+
ItemEnum::AssociatedConstItem(_, _) |
560+
ItemEnum::AssociatedTypeItem(_, _) => true,
561+
_ => false,
562+
}
563+
}
555564
}
556565

557566
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]

src/librustdoc/html/render.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -3881,19 +3881,21 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
38813881
RenderMode::ForDeref { mut_: deref_mut_ } => should_render_item(&item, deref_mut_),
38823882
};
38833883

3884-
let (mut is_hidden, extra_class) = if item.doc_value().is_some() {
3884+
let (is_hidden, extra_class) = if trait_.is_none() ||
3885+
item.doc_value().is_some() ||
3886+
item.inner.is_associated() {
38853887
(false, "")
38863888
} else {
38873889
(true, " hidden")
38883890
};
38893891
match item.inner {
38903892
clean::MethodItem(clean::Method { ref decl, .. }) |
3891-
clean::TyMethodItem(clean::TyMethod{ ref decl, .. }) => {
3893+
clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => {
38923894
// Only render when the method is not static or we allow static methods
38933895
if render_method_item {
38943896
let id = cx.derive_id(format!("{}.{}", item_type, name));
38953897
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
3896-
write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
3898+
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
38973899
write!(w, "{}", spotlight_decl(decl)?)?;
38983900
write!(w, "<span id='{}' class='invisible'>", ns_id)?;
38993901
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
39103912
render_stability_since_raw(w, item.stable_since(), outer_version)?;
39113913
}
39123914
write!(w, "</td></tr></tbody></table></span></h4>")?;
3913-
is_hidden = false;
39143915
}
39153916
}
39163917
clean::TypedefItem(ref tydef, _) => {

src/librustdoc/html/static/main.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -2059,12 +2059,22 @@
20592059
onEach(document.getElementsByClassName('impl'), func);
20602060
onEach(document.getElementsByClassName('impl-items'), function(e) {
20612061
onEach(e.getElementsByClassName('associatedconstant'), func);
2062-
if (e.getElementsByClassName('hidden').length > 0) {
2062+
var hiddenElems = e.getElementsByClassName('hidden');
2063+
var needToggle = false;
2064+
2065+
for (var i = 0; i < hiddenElems.length; ++i) {
2066+
if (hasClass(hiddenElems[i], "content") === false &&
2067+
hasClass(hiddenElems[i], "docblock") === false) {
2068+
needToggle = true;
2069+
break;
2070+
}
2071+
}
2072+
if (needToggle === true) {
20632073
var newToggle = document.createElement('a');
20642074
newToggle.href = 'javascript:void(0)';
20652075
newToggle.className = 'collapse-toggle hidden-default collapsed';
20662076
newToggle.innerHTML = "[<span class='inner'>" + labelForToggleButton(true) + "</span>" +
2067-
"] Show hidden default items";
2077+
"] Show hidden undocumented items";
20682078
newToggle.onclick = function() {
20692079
if (hasClass(this, "collapsed")) {
20702080
removeClass(this, "collapsed");
@@ -2075,7 +2085,7 @@
20752085
}
20762086
}, true);
20772087
this.innerHTML = "[<span class='inner'>" + labelForToggleButton(false) +
2078-
"</span>] Hide default items"
2088+
"</span>] Hide undocumented items"
20792089
} else {
20802090
addClass(this, "collapsed");
20812091
onEach(this.parentNode.getElementsByClassName("x"), function(x) {
@@ -2085,7 +2095,7 @@
20852095
}
20862096
}, true);
20872097
this.innerHTML = "[<span class='inner'>" + labelForToggleButton(true) +
2088-
"</span>] Show hidden default items";
2098+
"</span>] Show hidden undocumented items";
20892099
}
20902100
};
20912101
e.insertBefore(newToggle, e.firstChild);

src/test/rustdoc/assoc-consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl Qux for Bar {
9999
/// Docs for QUX1 in impl.
100100
const QUX1: i8 = 5;
101101
// @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
102-
// @has - '//*[@class="docblock hidden"]' "Docs for QUX_DEFAULT12 in trait."
102+
// @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
103103
const QUX_DEFAULT0: u16 = 6;
104104
// @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
105105
// @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl."

src/test/rustdoc/manual_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl T for S2 {
7474
// @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
7575
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
7676
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
77-
// @has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
77+
// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait a_method definition.'
7878
pub struct S3(usize);
7979

8080
/// Docs associated with the S3 trait implementation.

0 commit comments

Comments
 (0)