Skip to content

Commit a545944

Browse files
Don't show associated const value anymore
1 parent 727eabd commit a545944

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

src/librustdoc/html/render.rs

+12-23
Original file line numberDiff line numberDiff line change
@@ -2198,8 +2198,7 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
21982198
info!("Documenting {}", name);
21992199
}
22002200
document_stability(w, cx, item)?;
2201-
let prefix = render_assoc_const_value(item);
2202-
document_full(w, item, cx, &prefix)?;
2201+
document_full(w, item, cx, "")?;
22032202
Ok(())
22042203
}
22052204

@@ -2231,20 +2230,6 @@ fn document_short(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, link
22312230
Ok(())
22322231
}
22332232

2234-
fn render_assoc_const_value(item: &clean::Item) -> String {
2235-
match item.inner {
2236-
clean::AssociatedConstItem(ref ty, Some(ref default)) => {
2237-
highlight::render_with_highlighting(
2238-
&format!("{}: {:#} = {}", item.name.as_ref().unwrap(), ty, default),
2239-
None,
2240-
None,
2241-
None,
2242-
)
2243-
}
2244-
_ => String::new(),
2245-
}
2246-
}
2247-
22482233
fn document_full(w: &mut fmt::Formatter, item: &clean::Item,
22492234
cx: &Context, prefix: &str) -> fmt::Result {
22502235
if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) {
@@ -3860,7 +3845,13 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
38603845
write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
38613846
write!(w, "<span id='{}' class='invisible'><code>", ns_id)?;
38623847
assoc_const(w, item, ty, default.as_ref(), link.anchor(&id))?;
3863-
write!(w, "</code></span></h4>\n")?;
3848+
let src = if let Some(l) = (Item { cx, item }).src_href() {
3849+
format!("<a class='srclink' href='{}' title='{}'>[src]</a>",
3850+
l, "goto source code")
3851+
} else {
3852+
String::new()
3853+
};
3854+
write!(w, "</code>{}</span></h4>\n", src)?;
38643855
}
38653856
clean::AssociatedTypeItem(ref bounds, ref default) => {
38663857
let id = cx.derive_id(format!("{}.{}", item_type, name));
@@ -3875,8 +3866,6 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
38753866
}
38763867

38773868
if render_method_item || render_mode == RenderMode::Normal {
3878-
let prefix = render_assoc_const_value(item);
3879-
38803869
if !is_default_item {
38813870
if let Some(t) = trait_ {
38823871
// The trait item may have been stripped so we might not
@@ -3886,23 +3875,23 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
38863875
// because impls can't have a stability.
38873876
document_stability(w, cx, it)?;
38883877
if item.doc_value().is_some() {
3889-
document_full(w, item, cx, &prefix)?;
3878+
document_full(w, item, cx, "")?;
38903879
} else if show_def_docs {
38913880
// In case the item isn't documented,
38923881
// provide short documentation from the trait.
3893-
document_short(w, cx, it, link, &prefix)?;
3882+
document_short(w, cx, it, link, "")?;
38943883
}
38953884
}
38963885
} else {
38973886
document_stability(w, cx, item)?;
38983887
if show_def_docs {
3899-
document_full(w, item, cx, &prefix)?;
3888+
document_full(w, item, cx, "")?;
39003889
}
39013890
}
39023891
} else {
39033892
document_stability(w, cx, item)?;
39043893
if show_def_docs {
3905-
document_short(w, cx, item, link, &prefix)?;
3894+
document_short(w, cx, item, link, "")?;
39063895
}
39073896
}
39083897
}

src/librustdoc/html/static/rustdoc.css

+8
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,14 @@ a {
559559
text-decoration: underline;
560560
}
561561

562+
.invisible > .srclink {
563+
position: absolute;
564+
top: 0;
565+
right: 0;
566+
font-size: 17px;
567+
font-weight: normal;
568+
}
569+
562570
.block a.current.crate { font-weight: 500; }
563571

564572
.search-container {

0 commit comments

Comments
 (0)