`format_code_in_doc_comments` should not touch non-rust code blocks
Open
@matthewhughes934 is already working on this.
Since Jul 23, 2025.
A-comments
C-bug
I-trailing-whitespace
only-with-option
UO-format_code_in_doc_comments
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
https://github.com/rust-lang/rustfmt/issues/3348
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 line
struct S;
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.