format_code_in_doc_comments removes parts of non-doc comments #4420
Labels
a-comments
bug
Panic, non-idempotency, invalid code, etc.
only-with-option
requires a non-default option value to reproduce
Describe the bug
All this happens only with
format_code_in_doc_comments=true
.A comment gets reformatted, during this reformatting the leading parts are removed.
This is triggered within enums and structs (perhaps other things, I haven't tried). The part that is removed has to follow the comment without a whitespace and start with a square opening bracket
[
. Everything attached to the bracket (without a whitespace) is removed.To Reproduce
When running this minimal example with
rustfmt --config format_code_in_doc_comments=true
The output is:
Instead of an enum, the top two lines could also be replaced with a struct, leading to the same buggy behavior:
Expected behavior
I would expect that the code is untouched by
rustfmt
.Meta
rustfmt
, but it also happens withcargo fmt
The text was updated successfully, but these errors were encountered: