From 1feccc1edfbd799bffcb82b3c639cc28531efe5a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 24 Apr 2025 11:51:11 +0200 Subject: [PATCH] Make impl item info come before doc --- src/librustdoc/html/render/mod.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 7e17f09aecdc..beaa6497b8ca 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2086,6 +2086,7 @@ fn render_impl( .split_summary_and_content() }) .unwrap_or((None, None)); + write!( w, "{}", @@ -2097,24 +2098,19 @@ fn render_impl( use_absolute, aliases, before_dox.as_deref(), + trait_.is_none() && impl_.items.is_empty(), ) )?; if toggled { w.write_str("")?; } - if before_dox.is_some() { - if trait_.is_none() && impl_.items.is_empty() { - w.write_str( - "
\ -
This impl block contains no items.
\ -
", - )?; - } - if let Some(after_dox) = after_dox { - write!(w, "
{after_dox}
")?; - } + if before_dox.is_some() + && let Some(after_dox) = after_dox + { + write!(w, "
{after_dox}
")?; } + if !default_impl_items.is_empty() || !impl_items.is_empty() { w.write_str("
")?; close_tags.push("
"); @@ -2182,6 +2178,7 @@ fn render_impl_summary( // in documentation pages for trait with automatic implementations like "Send" and "Sync". aliases: &[String], doc: Option<&str>, + impl_is_empty: bool, ) -> impl fmt::Display { fmt::from_fn(move |w| { let inner_impl = i.inner_impl(); @@ -2237,6 +2234,13 @@ fn render_impl_summary( } if let Some(doc) = doc { + if impl_is_empty { + w.write_str( + "
\ +
This impl block contains no items.
\ +
", + )?; + } write!(w, "
{doc}
")?; }