Skip to content

Commit c8d58a3

Browse files
committed
Add links for impls
Implements a solution for issue #23552
1 parent 1b08e0f commit c8d58a3

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/librustdoc/html/render.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,13 @@ fn render_deref_methods(w: &mut fmt::Formatter, cx: &Context, impl_: &Impl,
29252925
fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLink,
29262926
render_mode: RenderMode, outer_version: Option<&str>) -> fmt::Result {
29272927
if render_mode == RenderMode::Normal {
2928-
write!(w, "<h3 class='impl'><span class='in-band'><code>{}</code>", i.inner_impl())?;
2928+
let id = derive_id(match i.inner_impl().trait_ {
2929+
Some(ref t) => format!("impl-{}", Escape(&format!("{:#}", t))),
2930+
None => "impl".to_string(),
2931+
});
2932+
write!(w, "<h3 id='{}' class='impl'><span class='in-band'><code>{}</code>",
2933+
id, i.inner_impl())?;
2934+
write!(w, "<a href='#{}' class='anchor'></a>", id)?;
29292935
write!(w, "</span><span class='out-of-band'>")?;
29302936
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
29312937
if let Some(l) = (Item { item: &i.impl_item, cx: cx }).src_href() {

src/librustdoc/html/static/rustdoc.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ a {
441441
.small-section-header:hover > .anchor {
442442
display: initial;
443443
}
444+
445+
.in-band:hover > .anchor {
446+
display: initial;
447+
}
444448
.anchor {
445449
display: none;
446450
}

src/librustdoc/html/static/styles/main.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ h1.fqn {
2626
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
2727
border-bottom-color: #DDDDDD;
2828
}
29-
.in-band {
30-
background-color: white;
31-
}
3229

3330
.docblock code, .docblock-short code {
3431
background-color: #F5F5F5;

0 commit comments

Comments
 (0)