Skip to content

Newlines in deprecation warning are handled strangely - double newlines are stripped completely #149732

Closed

Description

@orlp

Code

pub struct A;

impl A {
    #[deprecated(note =
"Foo some.
Bar sentence.")]
    /// Function 1.
    pub fn func1() {}

    #[deprecated(note =
"Foo some.

Bar sentence.")]
    /// Function 2.
    pub fn func2() {}
}

Reproduction Steps

cargo doc

Expected Outcome

I would expect single newlines to get replaced with a space, and double newlines to start a new paragraph, like in the rest of the documentation.

Actual Output

Single newlines are kept verbatim, double newlines are stripped entirely. Note the lack of a space between sentences in func2:

Image

Version

rustdoc 1.93.0-nightly (25d319a 2025-11-11)

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Dec 7, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Dec 7, 2025
  3. self-assigned this
    on Dec 7, 2025
  4. lolbinarycat commented on Dec 7, 2025

    @lolbinarycat
    Contributor

    pub(crate) fn write_into(self, mut f: impl fmt::Write) -> fmt::Result {

    It seems like we're doing some kinda odd stuff, only partially interpreting these strings as markdown (for example, they're styled with white-space: pre-wrap.

  5. lolbinarycat commented on Dec 7, 2025

    @lolbinarycat
    Contributor

    Yeah, strangely, this seems to be intentional behavior, we are explicitly removing the Tag::Paragraph events, but that seems very ill advised. I believe this is actually working around a quirk in write_html_fmt where it adds \n between <p> elements, but there are better ways of doing that.

  6. lolbinarycat commented on Apr 6, 2026

    @lolbinarycat
    Contributor

    fixed by #149931

  7. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions