From 45964368f4a2e31c94e9bcf1cef933c087d21544 Mon Sep 17 00:00:00 2001 From: François Mockers Date: Thu, 11 Mar 2021 03:32:30 +0100 Subject: add anchors links on hover to items from trait impl --- src/librustdoc/html/render/mod.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/librustdoc/html/render') diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index a95cfc11367..9f9a3acd852 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1453,12 +1453,13 @@ fn render_impl( } else { (true, " hidden") }; + let in_trait_class = if trait_.is_some() { " trait-impl" } else { "" }; match *item.kind { clean::MethodItem(..) | clean::TyMethodItem(_) => { // Only render when the method is not static or we allow static methods if render_method_item { let id = cx.derive_id(format!("{}.{}", item_type, name)); - write!(w, "

", id, item_type, extra_class); + write!(w, "

", id, item_type, extra_class, in_trait_class); w.write_str(""); render_assoc_item(w, item, link.anchor(&id), ItemType::Impl, cx); w.write_str(""); @@ -1469,13 +1470,14 @@ fn render_impl( outer_version, outer_const_version, ); + write!(w, "", id); write_srclink(cx, item, w); w.write_str("

"); } } clean::TypedefItem(ref tydef, _) => { let id = cx.derive_id(format!("{}.{}", ItemType::AssocType, name)); - write!(w, "

", id, item_type, extra_class); + write!(w, "

", id, item_type, extra_class, in_trait_class); assoc_type( w, item, @@ -1486,11 +1488,13 @@ fn render_impl( cx.cache(), tcx, ); - w.write_str("

"); + w.write_str("
"); + write!(w, "", id); + w.write_str("

"); } clean::AssocConstItem(ref ty, ref default) => { let id = cx.derive_id(format!("{}.{}", item_type, name)); - write!(w, "

", id, item_type, extra_class); + write!(w, "

", id, item_type, extra_class, in_trait_class); assoc_const(w, item, ty, default.as_ref(), link.anchor(&id), "", cx); w.write_str(""); render_stability_since_raw( @@ -1500,12 +1504,13 @@ fn render_impl( outer_version, outer_const_version, ); + write!(w, "", id); write_srclink(cx, item, w); w.write_str("

"); } clean::AssocTypeItem(ref bounds, ref default) => { let id = cx.derive_id(format!("{}.{}", item_type, name)); - write!(w, "

", id, item_type, extra_class); + write!(w, "

", id, item_type, extra_class, in_trait_class); assoc_type( w, item, @@ -1516,7 +1521,9 @@ fn render_impl( cx.cache(), tcx, ); - w.write_str("

"); + w.write_str("
"); + write!(w, "", id); + w.write_str("

"); } clean::StrippedItem(..) => return, _ => panic!("can't make docs for trait item with name {:?}", item.name), -- cgit 1.4.1-3-g733a5