diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-07-07 18:06:54 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-07 18:06:54 +0530 |
| commit | f242e295e46b5b45e4e55e1d983dc3b8d11c746a (patch) | |
| tree | 1c6b7fa196a892d960d11d724ca1514ff61ac3c1 /src/librustdoc/html/render | |
| parent | 71b3fbdb47d940ccdb2aef06cf3f989057e30824 (diff) | |
| parent | 7967152eeeffbf86f20186d08f6faff1c859a211 (diff) | |
| download | rust-f242e295e46b5b45e4e55e1d983dc3b8d11c746a.tar.gz rust-f242e295e46b5b45e4e55e1d983dc3b8d11c746a.zip | |
Rollup merge of #98973 - GuillaumeGomez:inherent-impl-anchors, r=notriddle
Remove (unused) inherent impl anchors This is something `@notriddle` realized a few days ago: we have unused anchors in the DOM. This PR removes them. You can test it [here](https://rustdoc.crud.net/imperio/inherent-impl-anchors/foo/index.html). r? `@notriddle`
Diffstat (limited to 'src/librustdoc/html/render')
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index e62a8bcfba6..796bd771518 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1412,7 +1412,10 @@ fn render_impl( id, item_type, in_trait_class, ); render_rightside(w, cx, item, containing_item, render_mode); - write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); + if trait_.is_some() { + // Anchors are only used on trait impls. + write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); + } w.write_str("<h4 class=\"code-header\">"); render_assoc_item( w, @@ -1435,7 +1438,10 @@ fn render_impl( id, item_type, in_trait_class ); render_rightside(w, cx, item, containing_item, render_mode); - write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); + if trait_.is_some() { + // Anchors are only used on trait impls. + write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); + } w.write_str("<h4 class=\"code-header\">"); assoc_const( w, @@ -1457,7 +1463,10 @@ fn render_impl( let source_id = format!("{}.{}", item_type, name); let id = cx.derive_id(source_id.clone()); write!(w, "<section id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class); - write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); + if trait_.is_some() { + // Anchors are only used on trait impls. + write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); + } w.write_str("<h4 class=\"code-header\">"); assoc_type( w, @@ -1480,7 +1489,10 @@ fn render_impl( "<section id=\"{}\" class=\"{}{} has-srclink\">", id, item_type, in_trait_class ); - write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); + if trait_.is_some() { + // Anchors are only used on trait impls. + write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); + } w.write_str("<h4 class=\"code-header\">"); assoc_type( w, |
