Skip to content

Extra blank line inserted before code blocks in doc comments #6695

@shulaoda

Description

@shulaoda

Summary

Doc comment formatting inconsistency when using wrap_comments = true with max_width = 20: an extra blank line is inserted before code blocks.

# rustfmt.toml
wrap_comments = true
max_width = 20
/// Some doc comment with code snippet:
///```
/// '\u{1F}
/// ```
pub struct Code {}

Additional Context

This issue was discovered while attempting to fix other issues in rust-lang/rustfmt.

The latest rustfmt (rustfmt 1.8.0-nightly (6ac1fcd7a3 2025-10-09)) produces the correct output without the extra blank line. This issue is being filed to track this regression and verify whether it gets fixed after the next sync from rust-lang/rustfmt to rust-lang/rust.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions