Skip to content

rustfmt formats non-rust code in doc comments #4753

Open
@msrd0

Description

@msrd0

Config

hard_tabs = true

Setting format_code_in_doc_comments = true does not change the behaviour of rustfmt for this input code.

Input

/*!
```yaml
foo:
  bar:
    rustfmt: "don't touch this"
```
*/

fn main() {
	println!("Hello, world!");
}

Output

cargo +nightly fmt changes the indentation in front of the rustfmt: "don't touch this" line from 4 spaces to one tab. However, that code block specifies yaml as the language and should therefore not be touched by rustfmt.

Meta

  • rustfmt version: rustfmt 1.4.36-nightly (7de6968 2021-02-07)
  • From where did you install rustfmt?: rustup

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions