rust-lang/rustfmt

`wrap_comments` overflows into codeblock fence

Closed this issue · 1 comments

When using a code block in a doc comment and wrap_comments is enabled, the comment will wrap into the next line making the following code block no longer valid a valid code block.

The syntax reference for rustdoc says that exact syntax is the Fenced Code Blocks section of the CommonMark specification. The CommonMark spec states: "A fenced code block may interrupt a paragraph, and does not require a blank line either before or after."

Example

Initial code:

/// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam
/// ```
/// let foo = 0;
/// ```
fn bar() {}

Result:

/// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam
/// lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam ```
/// let foo = 0;
/// ```

Expected:

/// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam
/// lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam 
/// ```
/// let foo = 0;
/// ```

Duplicate of #5244