From ce6472987d2cb466345a857cb2efdd06307c5ebf Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Thu, 3 Jun 2021 10:28:43 -0700 Subject: [PATCH 1/8] Remove methods under Implementors on trait pages These were hidden by default, and duplicated information already on the page anyhow. Also remove the "Auto-hide trait implementors of a trait" setting, which is not needed anymore. --- src/librustdoc/html/render/mod.rs | 38 +++++++++++++++++------------- src/librustdoc/html/static/main.js | 5 ---- src/test/rustdoc/issue-19055.rs | 20 ---------------- 3 files changed, 21 insertions(+), 42 deletions(-) delete mode 100644 src/test/rustdoc/issue-19055.rs diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 0efa014b12748..4f3acfb8e82f7 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -490,7 +490,6 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result"); write!(w, "
"); @@ -1571,21 +1573,23 @@ fn render_impl( } } - if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) { - let mut ids = cx.id_map.borrow_mut(); - write!( - w, - "
{}
", - Markdown( - &*dox, - &i.impl_item.links(cx), - &mut ids, - cx.shared.codes, - cx.shared.edition(), - &cx.shared.playground - ) - .into_string() - ); + if !on_trait_page { + if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) { + let mut ids = cx.id_map.borrow_mut(); + write!( + w, + "
{}
", + Markdown( + &*dox, + &i.impl_item.links(cx), + &mut ids, + cx.shared.codes, + cx.shared.edition(), + &cx.shared.playground + ) + .into_string() + ); + } } } if !default_impl_items.is_empty() || !impl_items.is_empty() { diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index e43a231d7570b..98128878999e4 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -778,7 +778,6 @@ function hideThemeButtonState() { } var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true"; - var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false"; var hideImplementations = getSettingValue("auto-hide-trait-implementations") === "true"; var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false"; @@ -796,10 +795,6 @@ function hideThemeButtonState() { setImplementorsTogglesOpen("blanket-implementations-list", false); } - if (!hideImplementors) { - setImplementorsTogglesOpen("implementors-list", true); - } - onEachLazy(document.getElementsByClassName("rustdoc-toggle"), function (e) { if (!hideLargeItemContents && hasClass(e, "type-contents-toggle")) { e.open = true; diff --git a/src/test/rustdoc/issue-19055.rs b/src/test/rustdoc/issue-19055.rs deleted file mode 100644 index dbaf744dc4712..0000000000000 --- a/src/test/rustdoc/issue-19055.rs +++ /dev/null @@ -1,20 +0,0 @@ -// @has issue_19055/trait.Any.html -pub trait Any {} - -impl<'any> Any + 'any { - // @has - '//*[@id="method.is"]' 'fn is' - pub fn is(&self) -> bool { loop {} } - - // @has - '//*[@id="method.downcast_ref"]' 'fn downcast_ref' - pub fn downcast_ref(&self) -> Option<&T> { loop {} } - - // @has - '//*[@id="method.downcast_mut"]' 'fn downcast_mut' - pub fn downcast_mut(&mut self) -> Option<&mut T> { loop {} } -} - -pub trait Foo { - fn foo(&self) {} -} - -// @has - '//*[@id="method.foo"]' 'fn foo' -impl Foo for Any {} From bff4f073c8bc09788c5111ef6f7aa2b74e75dc89 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Tue, 8 Jun 2021 10:39:57 -0700 Subject: [PATCH 2/8] Use render_impl_summary when rendering traits. --- src/librustdoc/html/render/mod.rs | 41 ++++++++++-------------- src/librustdoc/html/render/print_item.rs | 31 +++++++----------- 2 files changed, 29 insertions(+), 43 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 4f3acfb8e82f7..4ce14e6eb3ce8 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1542,15 +1542,10 @@ fn render_impl( } } if render_mode == RenderMode::Normal { - let on_trait_page = matches!(*parent.kind, clean::ItemKind::TraitItem(_)); - let has_impl_items = !(impl_items.is_empty() && default_impl_items.is_empty()); - let toggled = !on_trait_page && has_impl_items; - let is_implementing_trait = i.inner_impl().trait_.is_some(); + let toggled = !(impl_items.is_empty() && default_impl_items.is_empty()); if toggled { close_tags.insert_str(0, "
"); write!(w, "
"); - } - if toggled { write!(w, "") } render_impl_summary( @@ -1573,23 +1568,21 @@ fn render_impl( } } - if !on_trait_page { - if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) { - let mut ids = cx.id_map.borrow_mut(); - write!( - w, - "
{}
", - Markdown( - &*dox, - &i.impl_item.links(cx), - &mut ids, - cx.shared.codes, - cx.shared.edition(), - &cx.shared.playground - ) - .into_string() - ); - } + if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) { + let mut ids = cx.id_map.borrow_mut(); + write!( + w, + "
{}
", + Markdown( + &*dox, + &i.impl_item.links(cx), + &mut ids, + cx.shared.codes, + cx.shared.edition(), + &cx.shared.playground + ) + .into_string() + ); } } if !default_impl_items.is_empty() || !impl_items.is_empty() { @@ -1601,7 +1594,7 @@ fn render_impl( w.write_str(&close_tags); } -fn render_impl_summary( +pub(crate) fn render_impl_summary( w: &mut Buffer, cx: &Context<'_>, i: &Impl, diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 88ec172a18bca..5be16d1ce5006 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -15,11 +15,11 @@ use rustc_span::symbol::{kw, sym, Symbol}; use super::{ collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl, render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre, - render_impl, render_stability_since_raw, write_srclink, AssocItemLink, Context, + render_impl_summary, render_stability_since_raw, write_srclink, AssocItemLink, Context, }; use crate::clean::{self, GetDefId}; use crate::formats::item_type::ItemType; -use crate::formats::{AssocItemRender, Impl, RenderMode}; +use crate::formats::{AssocItemRender, Impl}; use crate::html::escape::Escape; use crate::html::format::{print_abi_with_space, print_where_clause, Buffer, PrintWithSpace}; use crate::html::highlight; @@ -691,22 +691,17 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra write_small_section_header(w, "foreign-impls", "Implementations on Foreign Types", ""); for implementor in foreign { - let provided_methods = implementor.inner_impl().provided_trait_methods(cx.tcx()); - let assoc_link = - AssocItemLink::GotoSource(implementor.impl_item.def_id, &provided_methods); - render_impl( + let outer_version = implementor.impl_item.stable_since(cx.tcx()); + let outer_const_version = implementor.impl_item.const_stable_since(cx.tcx()); + render_impl_summary( w, cx, &implementor, - it, - assoc_link, - RenderMode::Normal, - implementor.impl_item.stable_since(cx.tcx()).as_deref(), - implementor.impl_item.const_stable_since(cx.tcx()).as_deref(), + outer_version.as_deref(), + outer_const_version.as_deref(), false, None, true, - false, &[], ); } @@ -1320,19 +1315,17 @@ fn render_implementor( } => implementor_dups[&path.last()].1, _ => false, }; - render_impl( + let outer_version = trait_.stable_since(cx.tcx()); + let outer_const_version = trait_.const_stable_since(cx.tcx()); + render_impl_summary( w, cx, implementor, - trait_, - AssocItemLink::Anchor(None), - RenderMode::Normal, - trait_.stable_since(cx.tcx()).as_deref(), - trait_.const_stable_since(cx.tcx()).as_deref(), + outer_version.as_deref(), + outer_const_version.as_deref(), false, Some(use_absolute), false, - false, aliases, ); } From 910c7fa7673b80ead337c5d37259c9ff4dcf355c Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Fri, 11 Jun 2021 22:16:44 -0700 Subject: [PATCH 3/8] Add doc(hidden) to all __iterator_get_unchecked This method on the Iterator trait is doc(hidden), and about half of implementations were doc(hidden). This adds the attribute to the remaining implementations. --- library/alloc/src/collections/vec_deque/into_iter.rs | 1 + library/alloc/src/collections/vec_deque/iter.rs | 1 + library/alloc/src/collections/vec_deque/iter_mut.rs | 1 + library/alloc/src/vec/into_iter.rs | 1 + library/core/src/array/iter.rs | 1 + library/core/src/iter/adapters/cloned.rs | 1 + library/core/src/iter/adapters/copied.rs | 1 + library/core/src/iter/adapters/enumerate.rs | 1 + library/core/src/iter/adapters/fuse.rs | 1 + library/core/src/iter/adapters/map.rs | 1 + library/core/src/iter/adapters/zip.rs | 1 + library/core/src/iter/range.rs | 1 + library/core/src/slice/iter.rs | 2 ++ library/core/src/str/iter.rs | 1 + 14 files changed, 15 insertions(+) diff --git a/library/alloc/src/collections/vec_deque/into_iter.rs b/library/alloc/src/collections/vec_deque/into_iter.rs index 1c635dd4f27fa..46a769a722a8b 100644 --- a/library/alloc/src/collections/vec_deque/into_iter.rs +++ b/library/alloc/src/collections/vec_deque/into_iter.rs @@ -38,6 +38,7 @@ impl Iterator for IntoIter { } #[inline] + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item where Self: TrustedRandomAccess, diff --git a/library/alloc/src/collections/vec_deque/iter.rs b/library/alloc/src/collections/vec_deque/iter.rs index f3eb228c9e380..ae1b03c9a4d22 100644 --- a/library/alloc/src/collections/vec_deque/iter.rs +++ b/library/alloc/src/collections/vec_deque/iter.rs @@ -103,6 +103,7 @@ impl<'a, T> Iterator for Iter<'a, T> { } #[inline] + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item where Self: TrustedRandomAccess, diff --git a/library/alloc/src/collections/vec_deque/iter_mut.rs b/library/alloc/src/collections/vec_deque/iter_mut.rs index 9493676e66bc8..df30c38652f72 100644 --- a/library/alloc/src/collections/vec_deque/iter_mut.rs +++ b/library/alloc/src/collections/vec_deque/iter_mut.rs @@ -89,6 +89,7 @@ impl<'a, T> Iterator for IterMut<'a, T> { } #[inline] + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item where Self: TrustedRandomAccess, diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index 8da4d995ba5c6..7a08f4c6cbaac 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -163,6 +163,7 @@ impl Iterator for IntoIter { self.len() } + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> Self::Item where Self: TrustedRandomAccess, diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs index aedbeab661058..931ea77eca4dc 100644 --- a/library/core/src/array/iter.rs +++ b/library/core/src/array/iter.rs @@ -132,6 +132,7 @@ impl Iterator for IntoIter { } #[inline] + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item where Self: TrustedRandomAccess, diff --git a/library/core/src/iter/adapters/cloned.rs b/library/core/src/iter/adapters/cloned.rs index 7efc155175c34..5cd65a9415fd7 100644 --- a/library/core/src/iter/adapters/cloned.rs +++ b/library/core/src/iter/adapters/cloned.rs @@ -58,6 +58,7 @@ where self.it.map(T::clone).fold(init, f) } + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> T where Self: TrustedRandomAccess, diff --git a/library/core/src/iter/adapters/copied.rs b/library/core/src/iter/adapters/copied.rs index def2408927589..07a3b5d245659 100644 --- a/library/core/src/iter/adapters/copied.rs +++ b/library/core/src/iter/adapters/copied.rs @@ -74,6 +74,7 @@ where self.it.count() } + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> T where Self: TrustedRandomAccess, diff --git a/library/core/src/iter/adapters/enumerate.rs b/library/core/src/iter/adapters/enumerate.rs index 91722a4b62a2e..8b27bdc60a705 100644 --- a/library/core/src/iter/adapters/enumerate.rs +++ b/library/core/src/iter/adapters/enumerate.rs @@ -111,6 +111,7 @@ where } #[rustc_inherit_overflow_checks] + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> ::Item where Self: TrustedRandomAccess, diff --git a/library/core/src/iter/adapters/fuse.rs b/library/core/src/iter/adapters/fuse.rs index aff48b1b220c4..0c21df4f12c60 100644 --- a/library/core/src/iter/adapters/fuse.rs +++ b/library/core/src/iter/adapters/fuse.rs @@ -114,6 +114,7 @@ where } #[inline] + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item where Self: TrustedRandomAccess, diff --git a/library/core/src/iter/adapters/map.rs b/library/core/src/iter/adapters/map.rs index 0bf9f4b0327e9..dc86eccfcb82f 100644 --- a/library/core/src/iter/adapters/map.rs +++ b/library/core/src/iter/adapters/map.rs @@ -122,6 +122,7 @@ where self.iter.fold(init, map_fold(self.f, g)) } + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> B where Self: TrustedRandomAccess, diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs index c95324c80ba61..8a6955060e82f 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs @@ -88,6 +88,7 @@ where } #[inline] + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item where Self: TrustedRandomAccess, diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index de5d77e96ee56..4a86d6a100abe 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -667,6 +667,7 @@ impl Iterator for ops::Range { } #[inline] + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item where Self: TrustedRandomAccess, diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 1ee662c6c8e3c..b2cb2f12bbfeb 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -2148,6 +2148,7 @@ impl<'a, T, const N: usize> Iterator for ArrayChunks<'a, T, N> { self.iter.last() } + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> &'a [T; N] { // SAFETY: The safety guarantees of `__iterator_get_unchecked` are // transferred to the caller. @@ -2260,6 +2261,7 @@ impl<'a, T, const N: usize> Iterator for ArrayChunksMut<'a, T, N> { self.iter.last() } + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> &'a mut [T; N] { // SAFETY: The safety guarantees of `__iterator_get_unchecked` are transferred to // the caller. diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index 6ec6b70b57119..a5774764573be 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -295,6 +295,7 @@ impl Iterator for Bytes<'_> { } #[inline] + #[doc(hidden)] unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> u8 { // SAFETY: the caller must uphold the safety contract // for `Iterator::__iterator_get_unchecked`. From 593d6d1cb15c55c88319470dabb40126c7b7f1e2 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Tue, 8 Jun 2021 11:04:53 -0700 Subject: [PATCH 4/8] Make portability part of the summary. That means it will be visible under "Implementors" on trait pages, and under "Implementations" on struct/enum pages, even when all methods are collapsed. Switch to a float layout for rightside elements. --- src/librustdoc/html/render/mod.rs | 17 ++++++++++++----- src/librustdoc/html/render/print_item.rs | 13 +++++++++---- src/librustdoc/html/static/rustdoc.css | 12 +++--------- src/test/rustdoc/src-links-auto-impls.rs | 6 +++--- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 4ce14e6eb3ce8..df8cc94d3ee13 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1552,6 +1552,7 @@ fn render_impl( w, cx, i, + parent, outer_version, outer_const_version, show_def_docs, @@ -1562,11 +1563,6 @@ fn render_impl( if toggled { write!(w, "
") } - if trait_.is_some() { - if let Some(portability) = portability(&i.impl_item, Some(parent)) { - write!(w, "
{}
", portability); - } - } if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) { let mut ids = cx.id_map.borrow_mut(); @@ -1598,6 +1594,7 @@ pub(crate) fn render_impl_summary( w: &mut Buffer, cx: &Context<'_>, i: &Impl, + parent: &clean::Item, outer_version: Option<&str>, outer_const_version: Option<&str>, show_def_docs: bool, @@ -1652,6 +1649,7 @@ pub(crate) fn render_impl_summary( ); } write!(w, "
", id); + write!(w, "
"); render_stability_since_raw( w, i.impl_item.stable_since(tcx).as_deref(), @@ -1660,6 +1658,15 @@ pub(crate) fn render_impl_summary( outer_const_version, ); write_srclink(cx, &i.impl_item, w); + w.write_str("
"); // end of "rightside" + + let is_trait = i.inner_impl().trait_.is_some(); + if is_trait { + if let Some(portability) = portability(&i.impl_item, Some(parent)) { + write!(w, "
{}
", portability); + } + } + w.write_str(""); } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 5be16d1ce5006..8ad0a80344176 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -585,11 +585,14 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra if toggled { write!(w, "
"); } - write!(w, "
", id); - render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx); - w.write_str(""); + write!(w, "
", id); + write!(w, "
"); render_stability_since(w, m, t, cx.tcx()); write_srclink(cx, m, w); + write!(w, "
"); + write!(w, ""); + render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx); + w.write_str(""); w.write_str("
"); if toggled { write!(w, "
"); @@ -697,6 +700,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra w, cx, &implementor, + it, outer_version.as_deref(), outer_const_version.as_deref(), false, @@ -1305,7 +1309,7 @@ fn render_implementor( implementor_dups: &FxHashMap, aliases: &[String], ) { - // If there's already another implementor that has the same abbridged name, use the + // If there's already another implementor that has the same abridged name, use the // full path, for example in `std::iter::ExactSizeIterator` let use_absolute = match implementor.inner_impl().for_ { clean::ResolvedPath { ref path, is_generic: false, .. } @@ -1321,6 +1325,7 @@ fn render_implementor( w, cx, implementor, + trait_, outer_version.as_deref(), outer_const_version.as_deref(), false, diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 7535145caa5c8..e084ee9ca7e34 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -581,7 +581,6 @@ nav.sub { .content .item-info { position: relative; margin-left: 33px; - margin-top: -13px; } .sub-variant > div > .item-info { @@ -852,12 +851,12 @@ body.blur > :not(#help) { } .stab { - display: table; border-width: 1px; border-style: solid; padding: 3px; margin-bottom: 5px; font-size: 90%; + font-weight: normal; } .stab p { display: inline; @@ -906,26 +905,22 @@ body.blur > :not(#help) { } .impl-items .since, .impl .since, .methods .since { - flex-grow: 0; padding-left: 12px; padding-right: 2px; position: initial; } .impl-items .srclink, .impl .srclink, .methods .srclink { - flex-grow: 0; /* Override header settings otherwise it's too bold */ font-size: 17px; font-weight: normal; } -.impl-items code, .impl code, .methods code { - flex-grow: 1; +.rightside { + float: right; } .has-srclink { - display: flex; - flex-basis: 100%; font-size: 16px; margin-bottom: 12px; /* Push the src link out to the right edge consistently */ @@ -986,7 +981,6 @@ a.test-arrow:hover{ } .since + .srclink { - display: table-cell; padding-left: 10px; } diff --git a/src/test/rustdoc/src-links-auto-impls.rs b/src/test/rustdoc/src-links-auto-impls.rs index 6f609e080d3dd..1952f723465d6 100644 --- a/src/test/rustdoc/src-links-auto-impls.rs +++ b/src/test/rustdoc/src-links-auto-impls.rs @@ -2,11 +2,11 @@ // @has foo/struct.Unsized.html // @has - '//div[@id="impl-Sized"]/code' 'impl !Sized for Unsized' -// @!has - '//div[@id="impl-Sized"]/a[@class="srclink"]' '[src]' +// @!has - '//div[@id="impl-Sized"]//a[@class="srclink"]' '[src]' // @has - '//div[@id="impl-Sync"]/code' 'impl Sync for Unsized' -// @!has - '//div[@id="impl-Sync"]/a[@class="srclink"]' '[src]' +// @!has - '//div[@id="impl-Sync"]//a[@class="srclink"]' '[src]' // @has - '//div[@id="impl-Any"]/code' 'impl Any for T' -// @has - '//div[@id="impl-Any"]/a[@class="srclink"]' '[src]' +// @has - '//div[@id="impl-Any"]//a[@class="srclink"]' '[src]' pub struct Unsized { data: [u8], } From 5de1391b88007a1d4f7b1517657a86aae352af1e Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sat, 12 Jun 2021 00:25:26 -0700 Subject: [PATCH 5/8] Factor out render_rightside This covers rendering of stability_since and the srclink across methods and trait implementations, so their DOM representation is consistent. --- src/librustdoc/html/render/mod.rs | 73 ++++++++----------- src/librustdoc/html/static/rustdoc.css | 8 -- src/test/rustdoc-gui/hash-item-expansion.goml | 3 - 3 files changed, 30 insertions(+), 54 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index df8cc94d3ee13..a210d0c843cc6 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1294,7 +1294,6 @@ fn render_impl( ) { let item_type = item.type_(); let name = item.name.as_ref().unwrap(); - let tcx = cx.tcx(); let render_method_item = match render_mode { RenderMode::Normal => true, @@ -1363,6 +1362,7 @@ fn render_impl( "
", id, item_type, in_trait_class, ); + render_rightside(w, cx, item, outer_version, outer_const_version); w.write_str(""); render_assoc_item( w, @@ -1372,15 +1372,7 @@ fn render_impl( cx, ); w.write_str(""); - render_stability_since_raw( - w, - item.stable_since(tcx).as_deref(), - item.const_stable_since(tcx).as_deref(), - outer_version, - outer_const_version, - ); write!(w, "", id); - write_srclink(cx, item, w); w.write_str("
"); } } @@ -1413,6 +1405,7 @@ fn render_impl( "
", id, item_type, in_trait_class ); + render_rightside(w, cx, item, outer_version, outer_const_version); assoc_const( w, item, @@ -1423,15 +1416,7 @@ fn render_impl( cx, ); w.write_str(""); - render_stability_since_raw( - w, - item.stable_since(tcx).as_deref(), - item.const_stable_since(tcx).as_deref(), - outer_version, - outer_const_version, - ); write!(w, "", id); - write_srclink(cx, item, w); w.write_str("
"); } clean::AssocTypeItem(ref bounds, ref default) => { @@ -1590,6 +1575,28 @@ fn render_impl( w.write_str(&close_tags); } +fn render_rightside( + w: &mut Buffer, + cx: &Context<'_>, + item: &clean::Item, + outer_version: Option<&str>, + outer_const_version: Option<&str>, +) { + let tcx = cx.tcx(); + + write!(w, "
"); + render_stability_since_raw( + w, + item.stable_since(tcx).as_deref(), + item.const_stable_since(tcx).as_deref(), + outer_version, + outer_const_version, + ); + + write_srclink(cx, item, w); + w.write_str("
"); +} + pub(crate) fn render_impl_summary( w: &mut Buffer, cx: &Context<'_>, @@ -1604,7 +1611,6 @@ pub(crate) fn render_impl_summary( // in documentation pages for trait with automatic implementations like "Send" and "Sync". aliases: &[String], ) { - let tcx = cx.tcx(); let id = cx.derive_id(match i.inner_impl().trait_ { Some(ref t) => { if is_on_foreign_type { @@ -1620,13 +1626,11 @@ pub(crate) fn render_impl_summary( } else { format!(" data-aliases=\"{}\"", aliases.join(",")) }; + write!(w, "
", id, aliases); + render_rightside(w, cx, &i.impl_item, outer_version, outer_const_version); + write!(w, ""); + if let Some(use_absolute) = use_absolute { - write!( - w, - "
\ - ", - id, aliases - ); write!(w, "{}", i.inner_impl().print(use_absolute, cx)); if show_def_docs { for it in &i.inner_impl().items { @@ -1637,28 +1641,11 @@ pub(crate) fn render_impl_summary( } } } - w.write_str(""); } else { - write!( - w, - "
\ - {}", - id, - aliases, - i.inner_impl().print(false, cx) - ); + write!(w, "{}", i.inner_impl().print(false, cx)); } + write!(w, ""); write!(w, "", id); - write!(w, "
"); - render_stability_since_raw( - w, - i.impl_item.stable_since(tcx).as_deref(), - i.impl_item.const_stable_since(tcx).as_deref(), - outer_version, - outer_const_version, - ); - write_srclink(cx, &i.impl_item, w); - w.write_str("
"); // end of "rightside" let is_trait = i.inner_impl().trait_.is_some(); if is_trait { diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index e084ee9ca7e34..e6646586c4125 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -899,9 +899,6 @@ body.blur > :not(#help) { .since { font-weight: normal; font-size: initial; - position: absolute; - right: 0; - top: 0; } .impl-items .since, .impl .since, .methods .since { @@ -1606,11 +1603,6 @@ details.undocumented[open] > summary::before { margin-left: 0; } - .content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant, - .impl-items > .associatedtype { - display: flex; - } - .anchor { display: none !important; } diff --git a/src/test/rustdoc-gui/hash-item-expansion.goml b/src/test/rustdoc-gui/hash-item-expansion.goml index 1248d11200e6c..d5f9d4fc58b8c 100644 --- a/src/test/rustdoc-gui/hash-item-expansion.goml +++ b/src/test/rustdoc-gui/hash-item-expansion.goml @@ -2,9 +2,6 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.borrow // In the blanket implementations list, "Borrow" is the second one, hence the ":nth(2)". assert: ("#blanket-implementations-list > details:nth-child(2)", "open", "") -// Please note the "\" below is needed because otherwise ".borrow" would be interpreted as -// a class selector. -assert: ("#method\.borrow", {"display": "flex"}) // We first check that the impl block is open by default. assert: ("#implementations + details", "open", "") // We collapse it. From c4fa6d58276c5a4a76c36fca6d4689db415c2817 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Wed, 16 Jun 2021 22:47:46 -0700 Subject: [PATCH 6/8] Move anchor earlier in the DOM for easier layout --- src/librustdoc/html/render/mod.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index a210d0c843cc6..521464b7b920c 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1363,6 +1363,7 @@ fn render_impl( id, item_type, in_trait_class, ); render_rightside(w, cx, item, outer_version, outer_const_version); + write!(w, "", id); w.write_str(""); render_assoc_item( w, @@ -1372,7 +1373,6 @@ fn render_impl( cx, ); w.write_str(""); - write!(w, "", id); w.write_str("
"); } } @@ -1381,9 +1381,11 @@ fn render_impl( let id = cx.derive_id(source_id.clone()); write!( w, - "
", + "
", id, item_type, in_trait_class ); + write!(w, "", id); + w.write_str(""); assoc_type( w, item, @@ -1394,7 +1396,6 @@ fn render_impl( cx, ); w.write_str(""); - write!(w, "", id); w.write_str("
"); } clean::AssocConstItem(ref ty, ref default) => { @@ -1402,10 +1403,12 @@ fn render_impl( let id = cx.derive_id(source_id.clone()); write!( w, - "
", + "
", id, item_type, in_trait_class ); render_rightside(w, cx, item, outer_version, outer_const_version); + write!(w, "", id); + w.write_str(""); assoc_const( w, item, @@ -1416,13 +1419,14 @@ fn render_impl( cx, ); w.write_str(""); - write!(w, "", id); w.write_str("
"); } clean::AssocTypeItem(ref bounds, ref default) => { let source_id = format!("{}.{}", item_type, name); let id = cx.derive_id(source_id.clone()); - write!(w, "
", id, item_type, in_trait_class,); + write!(w, "
", id, item_type, in_trait_class,); + write!(w, "", id); + w.write_str(""); assoc_type( w, item, @@ -1433,7 +1437,6 @@ fn render_impl( cx, ); w.write_str(""); - write!(w, "", id); w.write_str("
"); } clean::StrippedItem(..) => return, @@ -1628,6 +1631,7 @@ pub(crate) fn render_impl_summary( }; write!(w, "
", id, aliases); render_rightside(w, cx, &i.impl_item, outer_version, outer_const_version); + write!(w, "", id); write!(w, ""); if let Some(use_absolute) = use_absolute { @@ -1645,7 +1649,6 @@ pub(crate) fn render_impl_summary( write!(w, "{}", i.inner_impl().print(false, cx)); } write!(w, ""); - write!(w, "", id); let is_trait = i.inner_impl().trait_.is_some(); if is_trait { From 2ac5c1721a523c77831a2efbbadb21921b8c8c96 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Wed, 16 Jun 2021 22:48:23 -0700 Subject: [PATCH 7/8] Fix target highlighting in rustdoc. Also factor out outer_version and const_outer_version into render_rightside. --- src/librustdoc/html/render/mod.rs | 47 ++++++++----------- src/librustdoc/html/render/print_item.rs | 10 +--- src/librustdoc/html/static/rustdoc.css | 4 ++ src/librustdoc/html/static/themes/ayu.css | 5 +- src/librustdoc/html/static/themes/dark.css | 5 +- src/librustdoc/html/static/themes/light.css | 5 +- src/test/rustdoc/ensure-src-link.rs | 2 +- .../trait-impl-items-links-and-anchors.rs | 8 ---- 8 files changed, 38 insertions(+), 48 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 521464b7b920c..499f33f14f562 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -723,6 +723,8 @@ fn short_item_info( extra_info } +// Render the list of items inside one of the sections "Trait Implementations", +// "Auto Trait Implementations," "Blanket Trait Implementations" (on struct/enum pages). fn render_impls( cx: &Context<'_>, w: &mut Buffer, @@ -745,8 +747,6 @@ fn render_impls( containing_item, assoc_link, RenderMode::Normal, - containing_item.stable_since(tcx).as_deref(), - containing_item.const_stable_since(tcx).as_deref(), true, None, false, @@ -1024,7 +1024,6 @@ fn render_assoc_items( Some(v) => v, None => return, }; - let tcx = cx.tcx(); let cache = cx.cache(); let (non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| i.inner_impl().trait_.is_none()); if !non_trait.is_empty() { @@ -1058,8 +1057,6 @@ fn render_assoc_items( containing_item, AssocItemLink::Anchor(None), render_mode, - containing_item.stable_since(tcx).as_deref(), - containing_item.const_stable_since(tcx).as_deref(), true, None, false, @@ -1260,8 +1257,6 @@ fn render_impl( parent: &clean::Item, link: AssocItemLink<'_>, render_mode: RenderMode, - outer_version: Option<&str>, - outer_const_version: Option<&str>, show_def_docs: bool, use_absolute: Option, is_on_foreign_type: bool, @@ -1278,17 +1273,18 @@ fn render_impl( // For trait implementations, the `interesting` output contains all methods that have doc // comments, and the `boring` output contains all methods that do not. The distinction is // used to allow hiding the boring methods. + // `containing_item` is used for rendering stability info. If the parent is a trait impl, + // `containing_item` will the grandparent, since trait impls can't have stability attached. fn doc_impl_item( boring: &mut Buffer, interesting: &mut Buffer, cx: &Context<'_>, item: &clean::Item, parent: &clean::Item, + containing_item: &clean::Item, link: AssocItemLink<'_>, render_mode: RenderMode, is_default_item: bool, - outer_version: Option<&str>, - outer_const_version: Option<&str>, trait_: Option<&clean::Trait>, show_def_docs: bool, ) { @@ -1362,7 +1358,7 @@ fn render_impl( "
", id, item_type, in_trait_class, ); - render_rightside(w, cx, item, outer_version, outer_const_version); + render_rightside(w, cx, item, containing_item); write!(w, "", id); w.write_str(""); render_assoc_item( @@ -1406,7 +1402,7 @@ fn render_impl( "
", id, item_type, in_trait_class ); - render_rightside(w, cx, item, outer_version, outer_const_version); + render_rightside(w, cx, item, containing_item); write!(w, "", id); w.write_str(""); assoc_const( @@ -1461,11 +1457,10 @@ fn render_impl( cx, trait_item, if trait_.is_some() { &i.impl_item } else { parent }, + parent, link, render_mode, false, - outer_version, - outer_const_version, trait_.map(|t| &t.trait_), show_def_docs, ); @@ -1478,9 +1473,8 @@ fn render_impl( t: &clean::Trait, i: &clean::Impl, parent: &clean::Item, + containing_item: &clean::Item, render_mode: RenderMode, - outer_version: Option<&str>, - outer_const_version: Option<&str>, show_def_docs: bool, ) { for trait_item in &t.items { @@ -1498,11 +1492,10 @@ fn render_impl( cx, trait_item, parent, + containing_item, assoc_link, render_mode, true, - outer_version, - outer_const_version, Some(t), show_def_docs, ); @@ -1522,9 +1515,8 @@ fn render_impl( &t.trait_, &i.inner_impl(), &i.impl_item, + parent, render_mode, - outer_version, - outer_const_version, show_def_docs, ); } @@ -1541,8 +1533,7 @@ fn render_impl( cx, i, parent, - outer_version, - outer_const_version, + parent, show_def_docs, use_absolute, is_on_foreign_type, @@ -1578,12 +1569,13 @@ fn render_impl( w.write_str(&close_tags); } +// Render the items that appear on the right side of methods, impls, and +// associated types. For example "1.0.0 (const: 1.39.0) [src]". fn render_rightside( w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, - outer_version: Option<&str>, - outer_const_version: Option<&str>, + containing_item: &clean::Item, ) { let tcx = cx.tcx(); @@ -1592,8 +1584,8 @@ fn render_rightside( w, item.stable_since(tcx).as_deref(), item.const_stable_since(tcx).as_deref(), - outer_version, - outer_const_version, + containing_item.stable_since(tcx).as_deref(), + containing_item.const_stable_since(tcx).as_deref(), ); write_srclink(cx, item, w); @@ -1605,8 +1597,7 @@ pub(crate) fn render_impl_summary( cx: &Context<'_>, i: &Impl, parent: &clean::Item, - outer_version: Option<&str>, - outer_const_version: Option<&str>, + containing_item: &clean::Item, show_def_docs: bool, use_absolute: Option, is_on_foreign_type: bool, @@ -1630,7 +1621,7 @@ pub(crate) fn render_impl_summary( format!(" data-aliases=\"{}\"", aliases.join(",")) }; write!(w, "
", id, aliases); - render_rightside(w, cx, &i.impl_item, outer_version, outer_const_version); + render_rightside(w, cx, &i.impl_item, containing_item); write!(w, "", id); write!(w, ""); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 8ad0a80344176..6eff452a13bdd 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -694,15 +694,12 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra write_small_section_header(w, "foreign-impls", "Implementations on Foreign Types", ""); for implementor in foreign { - let outer_version = implementor.impl_item.stable_since(cx.tcx()); - let outer_const_version = implementor.impl_item.const_stable_since(cx.tcx()); render_impl_summary( w, cx, &implementor, it, - outer_version.as_deref(), - outer_const_version.as_deref(), + &implementor.impl_item, false, None, true, @@ -1319,15 +1316,12 @@ fn render_implementor( } => implementor_dups[&path.last()].1, _ => false, }; - let outer_version = trait_.stable_since(cx.tcx()); - let outer_const_version = trait_.const_stable_since(cx.tcx()); render_impl_summary( w, cx, implementor, trait_, - outer_version.as_deref(), - outer_const_version.as_deref(), + trait_, false, Some(use_absolute), false, diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index e6646586c4125..9a59ee528a0c9 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1037,6 +1037,10 @@ a.test-arrow:hover{ opacity: 1; } +:target { + padding-right: 3px; +} + .information { position: absolute; left: -25px; diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css index d220d8708a123..171d06c0a3667 100644 --- a/src/librustdoc/html/static/themes/ayu.css +++ b/src/librustdoc/html/static/themes/ayu.css @@ -334,8 +334,11 @@ a.test-arrow:hover { color: #999; } -:target > code, :target > .in-band { +:target, :target * { background: rgba(255, 236, 164, 0.06); +} + +:target { border-right: 3px solid rgba(255, 180, 76, 0.85); } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 6385a763f2ef7..d9ea28058ad99 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -282,8 +282,11 @@ a.test-arrow:hover{ color: #999; } -:target > code, :target > .in-band { +:target, :target * { background-color: #494a3d; +} + +:target { border-right: 3px solid #bb7410; } diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index c19d5bfc317f7..a2dfb89820b01 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -275,8 +275,11 @@ a.test-arrow:hover{ color: #999; } -:target > code, :target > .in-band { +:target, :target * { background: #FDFFD3; +} + +:target { border-right: 3px solid #ffb44c; } diff --git a/src/test/rustdoc/ensure-src-link.rs b/src/test/rustdoc/ensure-src-link.rs index 4b6270b26da27..6189acb72542a 100644 --- a/src/test/rustdoc/ensure-src-link.rs +++ b/src/test/rustdoc/ensure-src-link.rs @@ -2,5 +2,5 @@ // This test ensures that the [src] link is present on traits items. -// @has foo/trait.Iterator.html '//div[@id="method.zip"]/a[@class="srclink"]' "[src]" +// @has foo/trait.Iterator.html '//div[@id="method.zip"]//a[@class="srclink"]' "[src]" pub use std::iter::Iterator; diff --git a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs index 5b7c04c0d4445..ddbe93febdc25 100644 --- a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs +++ b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs @@ -38,23 +38,15 @@ impl MyTrait for Vec { } impl MyTrait for MyStruct { - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-3"]//a[@class="type"]/@href' #associatedtype.Assoc - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3 // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="type"]/@href' trait.MyTrait.html#associatedtype.Assoc // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc type Assoc = bool; - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-3"]//a[@class="constant"]/@href' #associatedconstant.VALUE - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3 // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedconstant.VALUE"]//a[@class="constant"]/@href' trait.MyTrait.html#associatedconstant.VALUE // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedconstant.VALUE"]//a[@class="anchor"]/@href' #associatedconstant.VALUE const VALUE: u32 = 20; - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.trait_function-2"]//a[@class="fnname"]/@href' #tymethod.trait_function - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.trait_function-2"]//a[@class="anchor"]/@href' #method.trait_function-2 // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.trait_function"]//a[@class="fnname"]/@href' trait.MyTrait.html#tymethod.trait_function // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function fn trait_function(&self) {} - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.defaulted_override-3"]//a[@class="fnname"]/@href' #method.defaulted_override - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.defaulted_override-3"]//a[@class="anchor"]/@href' #method.defaulted_override-3 // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.defaulted_override"]//a[@class="fnname"]/@href' trait.MyTrait.html#method.defaulted_override // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.defaulted_override"]//a[@class="anchor"]/@href' #method.defaulted_override fn defaulted_override(&self) {} From bf81e139af3605144121d736c0314d103466507c Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Wed, 16 Jun 2021 14:50:25 -0700 Subject: [PATCH 8/8] Restore details for Impls on Foreign Types These were previously removed along with the details in the "Implementors" section of trait pages. But for "Implementations on Foreign Types," we need to include the details because they will not be documented anywhere else. --- src/librustdoc/html/render/print_item.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 6eff452a13bdd..8fd5353891221 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -15,11 +15,12 @@ use rustc_span::symbol::{kw, sym, Symbol}; use super::{ collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl, render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre, - render_impl_summary, render_stability_since_raw, write_srclink, AssocItemLink, Context, + render_impl, render_impl_summary, render_stability_since_raw, write_srclink, AssocItemLink, + Context, }; use crate::clean::{self, GetDefId}; use crate::formats::item_type::ItemType; -use crate::formats::{AssocItemRender, Impl}; +use crate::formats::{AssocItemRender, Impl, RenderMode}; use crate::html::escape::Escape; use crate::html::format::{print_abi_with_space, print_where_clause, Buffer, PrintWithSpace}; use crate::html::highlight; @@ -694,15 +695,20 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra write_small_section_header(w, "foreign-impls", "Implementations on Foreign Types", ""); for implementor in foreign { - render_impl_summary( + let provided_methods = implementor.inner_impl().provided_trait_methods(cx.tcx()); + let assoc_link = + AssocItemLink::GotoSource(implementor.impl_item.def_id, &provided_methods); + render_impl( w, cx, &implementor, it, - &implementor.impl_item, + assoc_link, + RenderMode::Normal, false, None, true, + false, &[], ); }