Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code in block doc comments are not formatted #5931

Open
magiclen opened this issue Oct 1, 2023 · 2 comments
Open

Code in block doc comments are not formatted #5931

magiclen opened this issue Oct 1, 2023 · 2 comments
Labels
a-comments only-with-option requires a non-default option value to reproduce

Comments

@magiclen
Copy link

magiclen commented Oct 1, 2023

With format_code_in_doc_comments = true, rustfmt 1.6.0-nightly can format code in line doc comments, but code in block doc comments cannot be formatted.

/// ```rust
/// println!("hello"); // formatted
/// ```

/**
```rust
   println!("hello");          // not formatted
```
*/

fn f() {}
@ytmimi
Copy link
Contributor

ytmimi commented Oct 2, 2023

Thanks for reaching out! If you write the doc comment as follows then it formats as expected.

/**
 * ```rust
 *    println!("hello");          // not formatted
 * ```
 */
fn f() {}

@ytmimi
Copy link
Contributor

ytmimi commented Oct 2, 2023

This seems like a limitation of how rustfmt handles block doc comments where lines don't start with leading *. linking the tracking issue for format_code_in_doc_comments #3348

@ytmimi ytmimi added the only-with-option requires a non-default option value to reproduce label Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments only-with-option requires a non-default option value to reproduce
Projects
None yet
Development

No branches or pull requests

2 participants