From 438b12617774fa989673968aad51e5eae03d0333 Mon Sep 17 00:00:00 2001 From: binarycat Date: Fri, 12 Dec 2025 14:38:01 -0600 Subject: [PATCH] rustdoc: don't give depreciation notes special handling --- src/librustdoc/html/markdown.rs | 12 +++++++----- src/librustdoc/html/markdown/tests.rs | 2 +- src/librustdoc/html/static/css/rustdoc.css | 1 - tests/rustdoc-html/deprecated.rs | 5 +++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index c472c20a7dc71..7b3198a194c4f 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -109,13 +109,15 @@ pub(crate) struct MarkdownWithToc<'a> { pub(crate) edition: Edition, pub(crate) playground: &'a Option, } -/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags + +/// A struct like `Markdown` that renders the markdown escaping HTML tags /// and includes no paragraph tags. pub(crate) struct MarkdownItemInfo<'a> { pub(crate) content: &'a str, pub(crate) links: &'a [RenderedLink], pub(crate) ids: &'a mut IdMap, } + /// A tuple struct like `Markdown` that renders only the first paragraph. pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]); @@ -1497,10 +1499,10 @@ impl<'a> MarkdownItemInfo<'a> { let p = SpannedLinkReplacer::new(p, links); let p = footnotes::Footnotes::new(p, existing_footnotes); let p = TableWrapper::new(p.map(|(ev, _)| ev)); - let p = p.filter(|event| { - !matches!(event, Event::Start(Tag::Paragraph) | Event::End(TagEnd::Paragraph)) - }); - html::write_html_fmt(&mut f, p) + // in legacy wrap mode, strip

elements to avoid them inserting newlines + html::write_html_fmt(&mut f, p)?; + + Ok(()) }) } } diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index 1c99ccc5228b1..3655a52deee68 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -472,7 +472,7 @@ fn test_markdown_html_escape() { let mut idmap = IdMap::new(); let mut output = String::new(); MarkdownItemInfo::new(input, &[], &mut idmap).write_into(&mut output).unwrap(); - assert_eq!(output, expect, "original: {}", input); + assert_eq!(output, format!("

{}

\n", expect), "original: {}", input); } t("`Struct<'a, T>`", "Struct<'a, T>"); diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index b770a0e2a0e41..8410e8c793e1c 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1585,7 +1585,6 @@ so that we can apply CSS-filters to change the arrow color in themes */ color: var(--main-color); background-color: var(--stab-background-color); width: fit-content; - white-space: pre-wrap; border-radius: 3px; display: inline; vertical-align: baseline; diff --git a/tests/rustdoc-html/deprecated.rs b/tests/rustdoc-html/deprecated.rs index a84657a3df5aa..c7db816cffcfc 100644 --- a/tests/rustdoc-html/deprecated.rs +++ b/tests/rustdoc-html/deprecated.rs @@ -30,3 +30,8 @@ pub struct W; // 'Deprecated: shorthand reason: code$' #[deprecated = "shorthand reason: `code`"] pub struct X; + +//@ matches deprecated/struct.Y.html '//*[@class="stab deprecated"]//p[1]' 'multiple' +//@ matches deprecated/struct.Y.html '//*[@class="stab deprecated"]//p[2]' 'paragraphs' +#[deprecated = "multiple\n\nparagraphs"] +pub struct Y;