diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index f9d6b4619cc..04be6dbb6f7 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -191,12 +191,6 @@ impl StylePath { } } -fn write_srclink(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) { - if let Some(l) = cx.src_href(item) { - write!(buf, "source", l) - } -} - #[derive(Debug, Eq, PartialEq, Hash)] struct ItemEntry { url: String, @@ -1691,7 +1685,9 @@ fn render_rightside( const_stable_since, ); let mut srclink = Buffer::empty_from(w); - write_srclink(cx, item, &mut srclink); + if let Some(l) = cx.src_href(item) { + write!(srclink, "source", l) + } if has_stability && !srclink.is_empty() { rightside.write_str(" · "); } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 6d0a825fec8..a5668b318dc 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -18,7 +18,7 @@ use std::rc::Rc; use super::{ collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_section, 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, + render_attributes_in_pre, render_impl, render_rightside, render_stability_since_raw, AssocItemLink, Context, ImplRenderingParameters, }; use crate::clean; @@ -709,14 +709,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean: write!(w, ""); } write!(w, "", id); - write!(w, ""); - - let has_stability = render_stability_since(w, m, t, cx.tcx()); - if has_stability { - w.write_str(" · "); - } - write_srclink(cx, m, w); - write!(w, ""); + render_rightside(w, cx, m, t, RenderMode::Normal); write!(w, ""); render_assoc_item( w, @@ -1260,7 +1253,13 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean:: w.write_str(")"); } w.write_str(""); - render_stability_since(w, variant, it, cx.tcx()); + render_stability_since_raw( + w, + variant.stable_since(cx.tcx()), + variant.const_stability(cx.tcx()), + it.stable_since(cx.tcx()), + it.const_stable_since(cx.tcx()), + ); w.write_str(""); use crate::clean::Variant; @@ -1591,21 +1590,6 @@ where w.write_str(""); } -fn render_stability_since( - w: &mut Buffer, - item: &clean::Item, - containing_item: &clean::Item, - tcx: TyCtxt<'_>, -) -> bool { - render_stability_since_raw( - w, - item.stable_since(tcx), - item.const_stability(tcx), - containing_item.stable_since(tcx), - containing_item.const_stable_since(tcx), - ) -} - fn compare_impl<'a, 'b>(lhs: &'a &&Impl, rhs: &'b &&Impl, cx: &Context<'_>) -> Ordering { let lhss = format!("{}", lhs.inner_impl().print(false, cx)); let rhss = format!("{}", rhs.inner_impl().print(false, cx));