You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
format_code_in_doc_comments should not touch non-rust code blocks #6609
When format_code_in_doc_comments is enabled, rustfmt will delete trailing blank lines in non-rust code blocks (e.g. blocks prefaced with ```text), and add a trailing whitespace to leading blank lines.
/// A doc comment.////// ```text/// /// A text block/// /// ```/// /// ^ A blank linestructS;
Formatting this, with latest nightly rustfmt as of today (rustfmt 1.8.0-nightly (9982d6462b 2025-07-20)), and the format_code_in_doc_comments option, will delete the trailing blank line in the text block, and add a trailing whitespace to the leading blank line.
@joshtriplett when you have a moment can you post a code snippet we can use to verify this. Also can you post what version of rustfmt you're using and any other additional configs besides format_code_in_doc_comments that you might be using?
Hi! I've not contributed to this repo before, but I'd be interested in looking into this issue if no-one else is already
That'd be great. I'm not aware of anyone actively working on this, so feel free to claim (tag rustbot user with the claim command in a comment on the issue)
Activity
ytmimi commentedon Jul 21, 2025
Related to #6015 because that example also shows rustfmt modifying
```textblocks.ytmimi commentedon Jul 21, 2025
@joshtriplett when you have a moment can you post a code snippet we can use to verify this. Also can you post what version of rustfmt you're using and any other additional configs besides
format_code_in_doc_commentsthat you might be using?joshtriplett commentedon Jul 21, 2025
@ytmimi Added an MCVE, and corrected the description of the problem.
matthewhughes934 commentedon Jul 22, 2025
Hi! I've not contributed to this repo before, but I'd be interested in looking into this issue if no-one else is already
calebcartwright commentedon Jul 23, 2025
That'd be great. I'm not aware of anyone actively working on this, so feel free to claim (tag
rustbotuser with theclaimcommand in a comment on the issue)matthewhughes934 commentedon Jul 23, 2025
great! In that case:
@rustbot claim
Fix incorrect whitespace modifications to non-rust code blocks
matthewhughes934 commentedon Jul 25, 2025
my attempt: #6615
Fix incorrect whitespace modifications to non-rust code blocks
Fix incorrect whitespace modifications to non-rust code blocks