rust-lang / rust-lang/rustfmt

rustfmt formats non-rust code in doc comments

Open
#4,753 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-comments only-with-option P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by running the provided reproducer with cargo +nightly fmt, hard_tabs = true, and format_code_in_doc_comments = true; compare the YAML block and Rust code with the reported output. Done means Rust code is formatted while the YAML block remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.