Skip to content

Commit 3d28ee3

Browse files
committed
Auto merge of #55646 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - #54162 (Hide default impls items) - #55555 (Make `-Z ls` list the actual filename of external dependencies) - #55567 (add test for deriving Debug on uninhabited enum) - #55568 (test that rustdoc doesn't overflow on a big enum) - #55598 (publish-toolstate: ping maintainers when a tool builds again) Failed merges: r? @ghost
2 parents 2ad8c7b + 723edf7 commit 3d28ee3

13 files changed

+429
-49
lines changed

Diff for: src/librustc_metadata/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl<'a, 'tcx> MetadataBlob {
400400
for (i, dep) in root.crate_deps
401401
.decode(self)
402402
.enumerate() {
403-
write!(out, "{} {}-{}\n", i + 1, dep.name, dep.hash)?;
403+
write!(out, "{} {}{}\n", i + 1, dep.name, dep.extra_filename)?;
404404
}
405405
write!(out, "\n")?;
406406
Ok(())

Diff for: src/librustdoc/clean/mod.rs

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

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

Diff for: src/librustdoc/html/render.rs

+41-25
Original file line numberDiff line numberDiff line change
@@ -2322,8 +2322,8 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
23222322
if let Some(ref name) = item.name {
23232323
info!("Documenting {}", name);
23242324
}
2325-
document_stability(w, cx, item)?;
2326-
document_full(w, item, cx, "")?;
2325+
document_stability(w, cx, item, false)?;
2326+
document_full(w, item, cx, "", false)?;
23272327
Ok(())
23282328
}
23292329

@@ -2332,44 +2332,53 @@ fn render_markdown(w: &mut fmt::Formatter,
23322332
cx: &Context,
23332333
md_text: &str,
23342334
links: Vec<(String, String)>,
2335-
prefix: &str)
2335+
prefix: &str,
2336+
is_hidden: bool)
23362337
-> fmt::Result {
23372338
let mut ids = cx.id_map.borrow_mut();
2338-
write!(w, "<div class='docblock'>{}{}</div>",
2339-
prefix, Markdown(md_text, &links, RefCell::new(&mut ids), cx.codes))
2339+
write!(w, "<div class='docblock{}'>{}{}</div>",
2340+
if is_hidden { " hidden" } else { "" },
2341+
prefix,
2342+
Markdown(md_text, &links, RefCell::new(&mut ids),
2343+
cx.codes))
23402344
}
23412345

23422346
fn document_short(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, link: AssocItemLink,
2343-
prefix: &str) -> fmt::Result {
2347+
prefix: &str, is_hidden: bool) -> fmt::Result {
23442348
if let Some(s) = item.doc_value() {
23452349
let markdown = if s.contains('\n') {
23462350
format!("{} [Read more]({})",
23472351
&plain_summary_line(Some(s)), naive_assoc_href(item, link))
23482352
} else {
23492353
plain_summary_line(Some(s))
23502354
};
2351-
render_markdown(w, cx, &markdown, item.links(), prefix)?;
2355+
render_markdown(w, cx, &markdown, item.links(), prefix, is_hidden)?;
23522356
} else if !prefix.is_empty() {
2353-
write!(w, "<div class='docblock'>{}</div>", prefix)?;
2357+
write!(w, "<div class='docblock{}'>{}</div>",
2358+
if is_hidden { " hidden" } else { "" },
2359+
prefix)?;
23542360
}
23552361
Ok(())
23562362
}
23572363

23582364
fn document_full(w: &mut fmt::Formatter, item: &clean::Item,
2359-
cx: &Context, prefix: &str) -> fmt::Result {
2365+
cx: &Context, prefix: &str, is_hidden: bool) -> fmt::Result {
23602366
if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) {
23612367
debug!("Doc block: =====\n{}\n=====", s);
2362-
render_markdown(w, cx, &*s, item.links(), prefix)?;
2368+
render_markdown(w, cx, &*s, item.links(), prefix, is_hidden)?;
23632369
} else if !prefix.is_empty() {
2364-
write!(w, "<div class='docblock'>{}</div>", prefix)?;
2370+
write!(w, "<div class='docblock{}'>{}</div>",
2371+
if is_hidden { " hidden" } else { "" },
2372+
prefix)?;
23652373
}
23662374
Ok(())
23672375
}
23682376

2369-
fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
2377+
fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
2378+
is_hidden: bool) -> fmt::Result {
23702379
let stabilities = short_stability(item, cx, true);
23712380
if !stabilities.is_empty() {
2372-
write!(w, "<div class='stability'>")?;
2381+
write!(w, "<div class='stability{}'>", if is_hidden { " hidden" } else { "" })?;
23732382
for stability in stabilities {
23742383
write!(w, "{}", stability)?;
23752384
}
@@ -3934,14 +3943,21 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
39343943
RenderMode::ForDeref { mut_: deref_mut_ } => should_render_item(&item, deref_mut_),
39353944
};
39363945

3946+
let (is_hidden, extra_class) = if trait_.is_none() ||
3947+
item.doc_value().is_some() ||
3948+
item.inner.is_associated() {
3949+
(false, "")
3950+
} else {
3951+
(true, " hidden")
3952+
};
39373953
match item.inner {
39383954
clean::MethodItem(clean::Method { ref decl, .. }) |
3939-
clean::TyMethodItem(clean::TyMethod{ ref decl, .. }) => {
3955+
clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => {
39403956
// Only render when the method is not static or we allow static methods
39413957
if render_method_item {
39423958
let id = cx.derive_id(format!("{}.{}", item_type, name));
39433959
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
3944-
write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
3960+
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
39453961
write!(w, "{}", spotlight_decl(decl)?)?;
39463962
write!(w, "<span id='{}' class='invisible'>", ns_id)?;
39473963
write!(w, "<table class='table-display'><tbody><tr><td><code>")?;
@@ -3963,15 +3979,15 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
39633979
clean::TypedefItem(ref tydef, _) => {
39643980
let id = cx.derive_id(format!("{}.{}", ItemType::AssociatedType, name));
39653981
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
3966-
write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
3982+
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
39673983
write!(w, "<span id='{}' class='invisible'><code>", ns_id)?;
39683984
assoc_type(w, item, &Vec::new(), Some(&tydef.type_), link.anchor(&id))?;
39693985
write!(w, "</code></span></h4>\n")?;
39703986
}
39713987
clean::AssociatedConstItem(ref ty, ref default) => {
39723988
let id = cx.derive_id(format!("{}.{}", item_type, name));
39733989
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
3974-
write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
3990+
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
39753991
write!(w, "<span id='{}' class='invisible'><code>", ns_id)?;
39763992
assoc_const(w, item, ty, default.as_ref(), link.anchor(&id))?;
39773993
let src = if let Some(l) = (Item { cx, item }).src_href() {
@@ -3985,7 +4001,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
39854001
clean::AssociatedTypeItem(ref bounds, ref default) => {
39864002
let id = cx.derive_id(format!("{}.{}", item_type, name));
39874003
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
3988-
write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
4004+
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
39894005
write!(w, "<span id='{}' class='invisible'><code>", ns_id)?;
39904006
assoc_type(w, item, bounds, default.as_ref(), link.anchor(&id))?;
39914007
write!(w, "</code></span></h4>\n")?;
@@ -4002,25 +4018,25 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
40024018
if let Some(it) = t.items.iter().find(|i| i.name == item.name) {
40034019
// We need the stability of the item from the trait
40044020
// because impls can't have a stability.
4005-
document_stability(w, cx, it)?;
4021+
document_stability(w, cx, it, is_hidden)?;
40064022
if item.doc_value().is_some() {
4007-
document_full(w, item, cx, "")?;
4023+
document_full(w, item, cx, "", is_hidden)?;
40084024
} else if show_def_docs {
40094025
// In case the item isn't documented,
40104026
// provide short documentation from the trait.
4011-
document_short(w, cx, it, link, "")?;
4027+
document_short(w, cx, it, link, "", is_hidden)?;
40124028
}
40134029
}
40144030
} else {
4015-
document_stability(w, cx, item)?;
4031+
document_stability(w, cx, item, is_hidden)?;
40164032
if show_def_docs {
4017-
document_full(w, item, cx, "")?;
4033+
document_full(w, item, cx, "", is_hidden)?;
40184034
}
40194035
}
40204036
} else {
4021-
document_stability(w, cx, item)?;
4037+
document_stability(w, cx, item, is_hidden)?;
40224038
if show_def_docs {
4023-
document_short(w, cx, item, link, "")?;
4039+
document_short(w, cx, item, link, "", is_hidden)?;
40244040
}
40254041
}
40264042
}

Diff for: src/librustdoc/html/static/main.js

+44
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,50 @@
20522052
onEach(document.getElementsByClassName('method'), func);
20532053
onEach(document.getElementsByClassName('associatedconstant'), func);
20542054
onEach(document.getElementsByClassName('impl'), func);
2055+
onEach(document.getElementsByClassName('impl-items'), function(e) {
2056+
onEach(e.getElementsByClassName('associatedconstant'), func);
2057+
var hiddenElems = e.getElementsByClassName('hidden');
2058+
var needToggle = false;
2059+
2060+
for (var i = 0; i < hiddenElems.length; ++i) {
2061+
if (hasClass(hiddenElems[i], "content") === false &&
2062+
hasClass(hiddenElems[i], "docblock") === false) {
2063+
needToggle = true;
2064+
break;
2065+
}
2066+
}
2067+
if (needToggle === true) {
2068+
var newToggle = document.createElement('a');
2069+
newToggle.href = 'javascript:void(0)';
2070+
newToggle.className = 'collapse-toggle hidden-default collapsed';
2071+
newToggle.innerHTML = "[<span class='inner'>" + labelForToggleButton(true) + "</span>" +
2072+
"] Show hidden undocumented items";
2073+
newToggle.onclick = function() {
2074+
if (hasClass(this, "collapsed")) {
2075+
removeClass(this, "collapsed");
2076+
onEach(this.parentNode.getElementsByClassName("hidden"), function(x) {
2077+
if (hasClass(x, "content") === false) {
2078+
removeClass(x, "hidden");
2079+
addClass(x, "x");
2080+
}
2081+
}, true);
2082+
this.innerHTML = "[<span class='inner'>" + labelForToggleButton(false) +
2083+
"</span>] Hide undocumented items"
2084+
} else {
2085+
addClass(this, "collapsed");
2086+
onEach(this.parentNode.getElementsByClassName("x"), function(x) {
2087+
if (hasClass(x, "content") === false) {
2088+
addClass(x, "hidden");
2089+
removeClass(x, "x");
2090+
}
2091+
}, true);
2092+
this.innerHTML = "[<span class='inner'>" + labelForToggleButton(true) +
2093+
"</span>] Show hidden undocumented items";
2094+
}
2095+
};
2096+
e.insertBefore(newToggle, e.firstChild);
2097+
}
2098+
});
20552099

20562100
function createToggle(otherMessage, fontSize, extraClass, show) {
20572101
var span = document.createElement('span');

Diff for: src/librustdoc/html/static/rustdoc.css

+19-12
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,6 @@ h4 > code, h3 > code, .invisible > code {
479479
margin-bottom: 15px;
480480
}
481481

482-
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
483-
margin-left: 20px;
484-
}
485-
.content .impl-items .docblock, .content .impl-items .stability {
486-
margin-bottom: .6em;
487-
}
488-
489-
.content .impl-items > .stability {
490-
margin-left: 40px;
491-
}
492-
493482
.content .docblock > .impl-items {
494483
margin-left: 20px;
495484
margin-top: -34px;
@@ -531,7 +520,20 @@ h4 > code, h3 > code, .invisible > code {
531520
top: -9px;
532521
left: -13px;
533522
}
534-
.methods > .stability {
523+
524+
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
525+
margin-left: 20px;
526+
}
527+
528+
.content .impl-items .docblock, .content .impl-items .stability {
529+
margin-bottom: .6em;
530+
}
531+
532+
.content .impl-items > .stability {
533+
margin-left: 40px;
534+
}
535+
536+
.methods > .stability, .content .impl-items > .stability {
535537
margin-top: -8px;
536538
}
537539

@@ -839,6 +841,11 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
839841
text-align: center;
840842
}
841843

844+
.collapse-toggle.hidden-default {
845+
position: relative;
846+
margin-left: 20px;
847+
}
848+
842849
.ghost {
843850
display: none;
844851
}

Diff for: src/librustdoc/html/static/storage.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ var mainTheme = document.getElementById("mainThemeStyle");
1515

1616
var savedHref = [];
1717

18-
function onEach(arr, func) {
18+
function onEach(arr, func, reversed) {
1919
if (arr && arr.length > 0 && func) {
20-
for (var i = 0; i < arr.length; i++) {
21-
if (func(arr[i]) === true) {
22-
return true;
20+
if (reversed !== true) {
21+
for (var i = 0; i < arr.length; ++i) {
22+
if (func(arr[i]) === true) {
23+
return true;
24+
}
25+
}
26+
} else {
27+
for (var i = arr.length - 1; i >= 0; --i) {
28+
if (func(arr[i]) === true) {
29+
return true;
30+
}
2331
}
2432
}
2533
}

Diff for: src/test/rustdoc/assoc-consts.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ pub trait Qux {
7575
/// Docs for QUX1 in trait.
7676
const QUX1: i8;
7777
// @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
78-
// @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT0 in trait."
79-
/// Docs for QUX_DEFAULT0 in trait.
78+
// @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
79+
/// Docs for QUX_DEFAULT12 in trait.
8080
const QUX_DEFAULT0: u16 = 1;
8181
// @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
8282
// @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait."
@@ -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"]' "Docs for QUX_DEFAULT0 in trait."
102+
// @has - '//*[@class="docblock hidden"]' "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."

0 commit comments

Comments
 (0)